Bug 75751 - switchdesk writes invalid shell script
Summary: switchdesk writes invalid shell script
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: switchdesk
Version: 8.0
Hardware: i386
OS: Linux
low
medium
Target Milestone: ---
Assignee: Than Ngo
QA Contact: David Lawrence
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2002-10-11 20:18 UTC by Need Real Name
Modified: 2007-03-27 03:57 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2004-02-03 20:51:23 UTC
Embargoed:


Attachments (Terms of Use)

Description Need Real Name 2002-10-11 20:18:46 UTC
Description of Problem:
'switchdesk' writes two files in the user's home directory: .Xclients and
.Xclients-default.

.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):
3.9.8-9

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 04:42:04 UTC
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 04:44:36 UTC
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 06:35:44 UTC
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 18:12:10 UTC
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
POSIXLY_CORRECT=y
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 18:17:58 UTC
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-07 01:20:07 UTC
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>
 
void
main()
{
    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-07 01:21:16 UTC
Would you close then.  I can't.

Comment 8 Mike A. Harris 2003-11-07 03:19:56 UTC
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 Than Ngo 2004-02-03 20:51:23 UTC
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.