Bug 75751 - switchdesk writes invalid shell script
switchdesk writes invalid shell script
Product: Red Hat Linux
Classification: Retired
Component: switchdesk (Show other bugs)
i386 Linux
low Severity medium
: ---
: ---
Assigned To: Ngo Than
David Lawrence
: EasyFix
Depends On:
  Show dependency treegraph
Reported: 2002-10-11 16:18 EDT by Need Real Name
Modified: 2007-03-26 23:57 EDT (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2004-02-03 15:51:23 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Need Real Name 2002-10-11 16:18:46 EDT
Description of Problem:
'switchdesk' writes two files in the user's home directory: .Xclients and

.Xclients-default is execed from .Xclients; however, the -default file does not
have the initial "#!/bin/sh" line that an executable shell script should have.

The script does work, but it is technically incorrect.

Version-Release number of selected component (if applicable):

Steps to Reproduce:
1. run switchdesk
2. examine ~/.Xclients-default
3. observe that it does not begin with #!/bin/sh

Additional Information:
As a separate enhancement request: IMHO ~/.Xclients should start with
'#!/bin/sh' and not '#!/bin/bash' for portability.  Only if it were really
dependent on some "bash-isms" should it specify /bin/bash.
Comment 1 Mike A. Harris 2002-10-26 00:42:04 EDT
Scripts which do not have a shebang are perfectly technically correct.
The OS uses the default shell automatically.  However, it isn't a big
deal to add a shebang, so I'll add #!/bin/bash which is our official
system shell (and not /bin/sh)
Comment 2 Mike A. Harris 2002-10-26 00:44:36 EDT
Also, I might as well note in case you're a purist...

/bin/sh is linked to bash on Red Hat Linux:

[mharris@devel BUILD]$ dir /bin/sh
lrwxrwxrwx    1 root     root            4 Sep 26 02:23 /bin/sh -> bash

... so, it makes no difference which is there as the same shell gets
used in either case.  Again, bash is the supported system shell, so
that is what we care about being there.

(Clarifying so as to avoid a pointless /bin/sh purist debate which will
end up in me doing what I've decided to do anyway)
Comment 3 Need Real Name 2002-12-07 01:35:44 EST
mharris wrote:  
Also, I might as well note in case you're a purist...  
/bin/sh is linked to bash on Red Hat Linux:  
[mharris@devel BUILD]$ dir /bin/sh  
lrwxrwxrwx    1 root     root            4 Sep 26 02:23 /bin/sh -> bash  
Yes, I know that sh is linked to bash -- I wasn't filing the report on 
'purist' grounds, so no need to worry there. ;) 
Thanks for clarifying the other issue regarding lack of an interpreter line.
Comment 4 Miloslav Trmac 2003-02-17 13:12:10 EST
I'm not a purist, but I'll play one here  ;-)

u-pl6:~/BIG/translate$ /bin/bash
u-pl6:~$ set |grep POSIX
u-pl6:~$ exit
u-pl6:~/BIG/translate$ /bin/sh
u-pl6:~/BIG/translate$ set |grep POSIX
u-pl6:~/BIG/translate$ exit

bash changes its behavior depending on whether it was invoked as bash or sh
Comment 5 Mike A. Harris 2003-02-17 13:17:58 EST
That's not a surprise.  It is documented behaviour and should be present
in the bash manpage.  When invoked as /bin/sh or with POSIXLY_CORRECT,
bash will definitely behave differently.  I still think it would have
been nice if RMS would have called it POSIX_ME_HARDER like he wanted
to originally though.
Comment 6 Behdad Esfahbod 2003-11-06 20:20:07 EST
Mike, you are not completely right.  I'm closing this old bug, as your
could would work anyway.  But about shebang's being technically
optional, I'm afraid not.  It's the shell that defaults to /bin/sh. 
If you use exec set of functions, it would not work without shebang. 
Here's an example:

Compile this one as 'a':
#include <unistd.h>
    execl("./x", "x", 0);

and write a simple script x:

echo "I'm x".

and try ./a, you see nothing.  Now add shebang to x, try ./a, you see
the output.
Comment 7 Behdad Esfahbod 2003-11-06 20:21:16 EST
Would you close then.  I can't.
Comment 8 Mike A. Harris 2003-11-06 22:19:56 EST
That isn't the proper way to invoke a shell script from a C program.
No surprise there.

Let's please not waste each other's time with a totally pointless
debate in a bug report though.

The purpose of this report ultimately is to request that a shebang
be added to a script because it is missing.  I will do that probably
in good time if it isn't done already, but it's a rather low priority
issue.  The bug can stay open until someone fixes it.  Part of the
reason switchdesk bugs are low priority is because we'd like to
completely remove switchdesk, but for some reason or another it
keeps sticking around.  ;o)   The switchdesk CVS repo is also
screwed up IIRC.

Just FYI, the proper way to invoke a shell script, is with the
interpreter as the first argument to exec*()

Anyway, all of the information required to fix and close this bug
report is within the bug report, no further comments are needed
from anyone.  Thanks for pinging me on it though.

Adding to tracker
Comment 9 Ngo Than 2004-02-03 15:51:23 EST
it's fixed in 4.0.0, which is available in rawhide.

Note You need to log in before you can comment on or make changes to this bug.