Announcement

Collapse
No announcement yet.

BASH script error from Servicemenu gives incorrect error message

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    BASH script error from Servicemenu gives incorrect error message

    Is this a bug?:

    I'm working on a Servicemenu that executes a bash script (as dozens of other service menus do). Through trial and error I find that if the script exits with an error (exit 1), Dolphin returns and error message that reads:

    Could not find the program '~/.local/share/kservices5/ServiceMenus/somefolder/somescript'
    This drove me crazy for hours and hours until I realized that it's Dolphin giving the wrong message. This happens if I use an indirect location for the bash script and the script exits with a 1. If I remove the "~" and replace it with "/home/username" the error message does not appear even when the script exits with 1.

    Friggin' wasted a bunch of time on this one.

    At the very least, Dolphin shouldn't give the wrong error message.

    Please Read Me

    #2
    "tilde expansion" is a shell expansion, one of many, like variable, file name globbing, brace... It's just like the common snag of quoting the tilde, f.ex.
    Code:
    $ cat "~/.profile"
    cat: '~/.profile': No such file or directory
    It could be argued that dolphin should use a shell, both to check for the script's existence and to run it, but I suspect that dolphin hands over the task to a slave process, and the complications of that, f.ex. signal handling, might make that a bad idea.

    However, I seem to recall KDE has had made that kind of change in the past,
    Regards, John Little

    Comment


      #3
      Originally posted by oshunluvr View Post
      This happens if I use an indirect location for the bash script and the script exits with a 1. If I remove the "~" and replace it with "/home/username" the error message does not appear even when the script exits with 1.
      You can use "$HOME" (which will expand inside double quotes, unlike the tilde...this is a POSIX definition) in place of "~". Generally better than hard coding "/home/username".

      Comment


        #4
        Originally posted by kubicle View Post
        You can use "$HOME" (which will expand inside double quotes, unlike the tilde...this is a POSIX definition) in place of "~". Generally better than hard coding "/home/username".
        Great idea - thanks.

        Does that fix the erroneous error message?

        Please Read Me

        Comment


          #5
          Originally posted by oshunluvr View Post
          Does that fix the erroneous error message?
          It should fix the error caused by the "~" not being expanded, but of course it won't fix other problems with the script (if you received an error exit 1 even with the hard coded home path).

          Comment


            #6
            Originally posted by kubicle View Post
            It should fix the error caused by the "~" not being expanded, but of course it won't fix other problems with the script (if you received an error exit 1 even with the hard coded home path).
            Roger that and thank you. I already changed to the $HOME usage vice using the tilde. I wasn't really having issues with the tilde per se, but using the variable seemed more "correct" if there is such a thing.

            I suppose it's asking a lot of Dolphin to trap errors from outside programs correctly every time. Mostly, it irked me that I spent too much time trying to figure out why the ServiceMenu couldn't locate the script instead of trouble shooting the script where the actual problem was. I think it's misleading and therefore should be a more generic error so one isn't lead down a primrose path.

            Please Read Me

            Comment

            Working...
            X