Results 1 to 4 of 4

Thread: gksu vs. gksudo with find regex command

  1. #1
    Join Date
    May 2008
    Location
    United Kingdom
    Beans
    4,717
    Distro
    Lubuntu 18.04 Bionic Beaver

    gksu vs. gksudo with find regex command

    I have something I'm finding very odd.

    Create a couple of files as follows:
    Code:
    $ touch abc.tmp abctmp
    Now run the following three find commands. Notice how the first three return the correct answer (abc.tmp), but the last one returns both files.
    Code:
    $ find . -regextype posix-egrep -regex '.*\.tmp' -print
    ./abc.tmp
    $ sudo find . -regextype posix-egrep -regex '.*\.tmp' -print
    ./abc.tmp
    $ gksudo -- find . -regextype posix-egrep -regex '.*\.tmp' -print
    ./abc.tmp
    $ gksu -- find . -regextype posix-egrep -regex '.*\.tmp' -print
    ./abc.tmp
    ./abctmp
    (Note: gksudo is the same as gksu --sudo-mode.)

    This is not exactly a problem for me, but I'd dearly love to understand why gksu does not perform as I expect.

    Can you tell me why gksu gives a different answer?

  2. #2
    Join Date
    Apr 2009
    Location
    Midwest, U.S.A.
    Beans
    1,209
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: gksu vs. gksudo with find regex command

    I honestly don't know the answer, but I can confirm identical results. However, double backslashes in the 'gksu' line gives your expected results...
    Code:
    gksu -- find . -regextype posix-egrep -regex '.*\\.tmp' -print
    Laptop: Dell Inspiron 8200 - Fedora 13 - Goddard
    Desktop: Self-Built - [Ku, Lu, Xu, U]buntu - Lucid 10.04.3 (LTS)
    Linux User: 498249 / Ubuntu User: 29241

  3. #3
    Join Date
    Jan 2006
    Beans
    Hidden!
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: gksu vs. gksudo with find regex command

    type gksudo
    type gksu
    gksu which find
    gksudo which find
    gksu type find
    gksudo type find

    I think that maybe gksu is an alias or something and the parameters are being interpreted twice.
    I am infallible, you should know that by now.
    "My favorite language is call STAR. It's extremely concise. It has exactly one verb '*', which does exactly what I want at the moment." --Larry Wall
    (02:15:31 PM) ***TimToady and snake oil go way back...
    42 lines of Perl - SHI - Home Site

  4. #4
    Join Date
    May 2008
    Location
    United Kingdom
    Beans
    4,717
    Distro
    Lubuntu 18.04 Bionic Beaver

    Re: gksu vs. gksudo with find regex command

    Quote Originally Posted by AlphaLexman View Post
    double backslashes in the 'gksu' line gives your expected results...
    I confirm that I get the same result as you.

    Weird! I wonder why? But that may give a hint for the answer.

    Quote Originally Posted by slavik View Post
    I think that maybe gksu is an alias or something and the parameters are being interpreted twice.
    According to the manual (man gksu or man gksudo), gksudo is equivalent to gksu --sudo-mode.

    I've just realised that gksu uses the su backend, and gksudo the sudo backend (unless using --su-mode or --sudo-mode). Read the manual for a better explanation. Therefore, it must be something to do with the difference between su and sudo.

    Taking into account AlphaLexman's discovery about the double-backslash, somehow the command must be passed to something that interprets the backslash when using su.

    However, both of the following commands give the correct result:
    Code:
    sudo su -c "find . -regextype posix-egrep -regex '.*\.tmp' -print"
    sudo su -c "find . -regextype posix-egrep -regex '.*\\.tmp' -print"
    Meanwhile, notice the following apparent contradiction. Line 4 supposedly should be the same as line 3.
    Code:
    gksu   --sudo-mode -- find . -regextype posix-egrep -regex '.*\.tmp' -print  # Does work
    gksudo             -- find . -regextype posix-egrep -regex '.*\.tmp' -print  # Does work
    gksu               -- find . -regextype posix-egrep -regex '.*\.tmp' -print  # Does not work
    gksudo --su-mode   -- find . -regextype posix-egrep -regex '.*\.tmp' -print  # Does work
    I remain nicely in the dark!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •