GtkDialog - tips

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Message
Author
User avatar
rcrsn51
Posts: 13096
Joined: Tue 05 Sep 2006, 13:50
Location: Stratford, Ontario

#1321 Post by rcrsn51 »

wiak wrote:When you say "same problem" I'm not sure what you mean.
When running in XenialPup32, I need to prefix <action> calls to exported functions with "bash -c ...".

wiak
Posts: 2040
Joined: Tue 11 Dec 2007, 05:12
Location: not Bulgaria

#1322 Post by wiak »

.
Last edited by wiak on Thu 07 Jun 2018, 12:46, edited 1 time in total.

User avatar
rcrsn51
Posts: 13096
Joined: Tue 05 Sep 2006, 13:50
Location: Stratford, Ontario

#1323 Post by rcrsn51 »

The good news is, backgrounding appears to work with quoting like this:

Code: Select all

<action>bash -c "FUNC &"</action>

wiak
Posts: 2040
Joined: Tue 11 Dec 2007, 05:12
Location: not Bulgaria

#1324 Post by wiak »

.
Last edited by wiak on Thu 07 Jun 2018, 12:46, edited 1 time in total.

User avatar
rcrsn51
Posts: 13096
Joined: Tue 05 Sep 2006, 13:50
Location: Stratford, Ontario

#1325 Post by rcrsn51 »

I tested the 64bit gtkwialog in Stretch-Live-64 and it works correctly, ie: <action>FUNC</action>

This also backgrounds correctly: <action>FUNC &</action>

wiak
Posts: 2040
Joined: Tue 11 Dec 2007, 05:12
Location: not Bulgaria

#1326 Post by wiak »

.
Last edited by wiak on Thu 07 Jun 2018, 12:47, edited 1 time in total.

User avatar
rcrsn51
Posts: 13096
Joined: Tue 05 Sep 2006, 13:50
Location: Stratford, Ontario

#1327 Post by rcrsn51 »

wiak wrote:So the results you were getting with the 32bit version may have been the correct results. Tomorrow will tell...wiak
That sounds like all gtkwialog apps, regardless of shell, would require <action>bash -c FUNC</action> to handle exported functions.

BTW, how will gtkwialog be more secure than gtkdialog? Either way, you are opening a new shell and running stuff in it.

step
Posts: 1349
Joined: Fri 04 May 2012, 11:20

#1328 Post by step »

wiak wrote:@step: Something wrong with your code line:

Code: Select all

               <action>. "'"$0"'" @test 1 2 3</action> 
@wiak, sorry I don't have time to read the thread right now; you might have figured this out already by yourself, but let me explain those quotes.

Keep the line above in context. It's part of variable DIALOG, which is quoted within single quotes. So the first single quote after <action> closes the single quote at the start of the string: DIALOG='....<action>. "' You can see now that the string part is quoted correctly. The next single quote after <action> closes the single quote at the end of the DIALOG string: '" @test 1 2 3</action>...' You can see that it's quoted correctly. We're left with "$0" in the middle part. Double quoting is the way to quote $0 (it doesn't need to be exported) to protect embedded spaces _and_ enable shell variable expansion. Finally, why did I add double quotes in '..."' before "$0" and in '"...' after "$0"? Consider who's doing what. First the shell expands "$0" to /path\ with\ spaces/script.sh. That's right, the shell _removes_ double quotes upon expanding $0. Then shell also unquotes the single-quoted prefix and suffix and concatenates all the parts together to set DIALOG. At this point DIALOG holds ...<action>. "/path with spaces/script.sh"</action>.... Now you can see where those red double quotes come from. Finally, _gtkdialog_ - when it runs the action - passes the string . "/path with spaces/script.sh" to /bin/sh, which executes the command by sourcing the path. Without the double quotes, the shell would report a File Not Found error on a path with embedded spaces.

I use the quoting pattern '..."' "$varname" '"...' when I'm embedding shell fragments, such as variables expanding to pathnames, in other scripting languages, like gtkdialog and awk.

You wrote that my example didn't work for you. I don't know why. Did you add any single or double quotes, or backslash escaped double quotes? I can't maintain that the above quoting pattern is unbreakable, especially in the light of differently patched gtkdialog versions, which add their own quoting rules. And bash quoting can be inconsistent. See this post, for instance, about mid way through the bash cons, where it says "Extremely complicated and inconsistent rules".

I confess writing gtkdialog scripts isn't my favorite thing. If I can get away with yad I will do, though yad comes with its own set of strange things and limitations. I know you've done a lot of exploratory work on IUP. In fact, I have started a project folder complete with your pets and notes. But I can't find enough time to play with all the new toys... so IUP is on hold for me ATM.
[url=http://murga-linux.com/puppy/viewtopic.php?t=117546]Fatdog64-810[/url]|[url=http://goo.gl/hqZtiB]+Packages[/url]|[url=http://goo.gl/6dbEzT]Kodi[/url]|[url=http://goo.gl/JQC4Vz]gtkmenuplus[/url]

User avatar
fredx181
Posts: 4448
Joined: Wed 11 Dec 2013, 12:37
Location: holland

#1329 Post by fredx181 »

Hi wiak,

I'm still testing but so far so good for me, congrats ! (tested your 32 bit mod)
I took existing script gdrive-gui2 (google-drive filemanager, my mod of mikeb's dropbox_gui) which is pretty complicated and having many "export -f " required functions.
So I changed all exported functions to "bash -c <function>" but one mistake, I made this(setting variable BUTTON):

Code: Select all

<action>BUTTON=3; bash -c add_selection</action>
That didn't work, took me a while to realize it had to be this:

Code: Select all

<action>bash -c "BUTTON=3; add_selection"</action
Ran the script after changing to sh > dash and everything OK.

Also ran the same modified script with sh > bash: also works OK.

Fine job ! Who knows, this will open new doors.

P.S. make sure you get enough sleep, take care of your health.
:wink:

Fred

wiak
Posts: 2040
Joined: Tue 11 Dec 2007, 05:12
Location: not Bulgaria

#1330 Post by wiak »

.
Last edited by wiak on Thu 07 Jun 2018, 12:47, edited 3 times in total.

wiak
Posts: 2040
Joined: Tue 11 Dec 2007, 05:12
Location: not Bulgaria

#1331 Post by wiak »

fredx181 wrote:Hi wiak,

I'm still testing but so far so good for me, congrats ! (tested your 32 bit mod)
I took existing script gdrive-gui2 (google-drive filemanager, my mod of mikeb's dropbox_gui) which is pretty complicated and having many "export -f " required functions.
So I changed all exported functions to "bash -c <function>"

Ran the script after changing to sh > dash and everything OK.

Also ran the same modified script with sh > bash: also works OK.

Fine job ! Who knows, this will open new doors.

P.S. make sure you get enough sleep, take care of your health.
:wink:

Fred
Good to hear! Thanks Fred. Yes, alas I'm becoming a bit exhausted because I'm only managing a little sleep because of pain. Also that makes concentrating when programming difficult. I'll post binary for 64bit gtkwialog once I'm out of bed again, but might be a couple of days.

wiak

wiak
Posts: 2040
Joined: Tue 11 Dec 2007, 05:12
Location: not Bulgaria

#1332 Post by wiak »

.
Last edited by wiak on Thu 07 Jun 2018, 12:48, edited 4 times in total.

wiak
Posts: 2040
Joined: Tue 11 Dec 2007, 05:12
Location: not Bulgaria

#1333 Post by wiak »

I'll start new thread for gtkwialog development/use discussions soonish to avoid further clogging up legacy gtkdialog tips thread
Last edited by wiak on Sun 27 May 2018, 02:15, edited 1 time in total.

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#1334 Post by technosaurus »

wiak wrote:I'll start new thread for gtkwialog development/use discussions soonish to avoid further clogging up legacy gtkwialog tips thread
gtkdialog development thread
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

wiak
Posts: 2040
Joined: Tue 11 Dec 2007, 05:12
Location: not Bulgaria

#1335 Post by wiak »

.
Last edited by wiak on Thu 07 Jun 2018, 12:48, edited 1 time in total.

wiak
Posts: 2040
Joined: Tue 11 Dec 2007, 05:12
Location: not Bulgaria

#1336 Post by wiak »

step wrote:
wiak wrote:@step: Something wrong with your code line:

Code: Select all

               <action>. "'"$0"'"
I use the quoting pattern '..."' "$varname" '"...' when I'm embedding shell fragments, such as variables expanding to pathnames, in other scripting languages, like gtkdialog and awk.
I have also often used that same quoting pattern to break things up so that wasn't the problem for me (probably used it in my domyfile app, cant remember where really), though your explanation of your intension in terms of its overall operation in this specific case is useful. No I didn't modify you example code at all - it just didn't work for me. I haven't had time to look into why.

Yes, I really think IUP is great. Has convenience advantages of yad and power of gtkdialog in a nicer syntax, and more power in addition to that. Alas, I too have been too occupied to use it further as yet.

Wiak

wiak
Posts: 2040
Joined: Tue 11 Dec 2007, 05:12
Location: not Bulgaria

#1337 Post by wiak »

.
Last edited by wiak on Thu 07 Jun 2018, 12:58, edited 1 time in total.

disciple
Posts: 6984
Joined: Sun 21 May 2006, 01:46
Location: Auckland, New Zealand

#1338 Post by disciple »

Hi guys,
Is anyone currently maintaining/developing an "upstream" gtkdialog? I thought thunor hadn't done anything on it for quite a while now.

I haven't followed this discussion too closely, so I'm afraid I may have missed a couple of things:
1. (not particularly relevant, but anyway:) any discussion of a context where this security concern was actually a real problem.
2. anyone actually suggesting that the changes in "gtkwialog" are undesirable, and current gtkdialog behaviour needs to remain the same.

It seems to me that:
- there is no upstream development , and
- there is some consensus that the old behaviour should be changed, and
- apps will only need relatively trivial changes to work with the new version.

If that is the case, forking seems rather gratuitous.
The world doesn't need yet another dialog program. It would be better for this to become upstream gtkdialog. Document and test the changes, get anyone interested to review it, and when it is ready release it with a new version number. We've survived changes in gtkdialog before; we can do it again.

Am I wrong?
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#1339 Post by technosaurus »

Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

disciple
Posts: 6984
Joined: Sun 21 May 2006, 01:46
Location: Auckland, New Zealand

#1340 Post by disciple »

Ah, thanks.
So it looks like Micko has taken over a very minimal "caretaker" maintenance role, and it would perhaps be worth having the discussion with him.
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER

Post Reply