kjepo@portofix.liu.se (Kjell Post) (10/13/87)
A little trick question for you all: what's happening here? % cat > \* date ^D % chmod +x \* % \* Tue Oct 13 03:13:08 MET 1987 % % cat > + date ^D % chmod +x + % + $ -- entered Bourne-shell Have a nice day -- ----------------------------------------------------------------------------- "The nice thing about standards is that you have so many to choose from" Dept of Computer & Info Science ...liuida!majestix.liu.se!kjepo Univ of Linkoping, Sweden (kjepo@majestix.liu.se)
schung@cory.Berkeley.EDU (Stephen the Greatest) (10/17/87)
In article <666@portofix.liu.se> kjepo@portofix.liu.se (Kjell Post) writes: > % cat > + > date > ^D > % chmod +x + > % + > $ -- entered Bourne-shell It works for me. It prints out the date-time. - Stephen
mkhaw@teknowledge-vaxc.ARPA (Mike Khaw) (10/17/87)
+---------- |> % cat > + |> date |> ^D |> % chmod +x + |> % + |> $ -- entered Bourne-shell | | It works for me. It prints out the date-time. +---------- I also get the date printed. Maybe "which +" will show that somewhere in your PATH, "+" is a link to /bin/sh. Mike Khaw -- internet: mkhaw@teknowledge-vaxc.arpa usenet: {uunet|sun|ucbvax|decwrl|uw-beaver}!mkhaw%teknowledge-vaxc.arpa USnail: Teknowledge Inc, 1850 Embarcadero Rd, POB 10119, Palo Alto, CA 94303
alen@cogen.UUCP (Alen Shapiro) (10/19/87)
In article <666@portofix.liu.se> kjepo@portofix.liu.se (Kjell Post) writes: >A little trick question for you all: what's happening here? > > % cat > \* > date > ^D > % chmod +x \* > % \* > Tue Oct 13 03:13:08 MET 1987 > % > % cat > + > date > ^D > % chmod +x + > % + > $ -- entered Bourne-shell > You have another '+' command, some sites use this command to give single command su status, but used by itself it gives you a root shell (if you pass the site dependent '+' id test). Try % which + to see where it is kept also % ./+ to resolve the conflict A related effect; A good way to spend a day debugging a working program is to call the test version of a program "test", since most sites have a /bin/test and the user usually has '.' last on his path list (can you say security), when you invoke the program (% test) /bin/test gets run not ./test and NOTHING will be printed. Using a debugger (dbx etc.) the program works fine but once back at command level it fails again. The answer of course is to assume the debugger is not worth a sh** and put print statements in the program, progressivly nearer to main() till some response is obtained. Since /bin/test is running, no response will ever be seen and the programmer will go quietly insane. (By the way, old versions of the test program ("o_test" etc.) magically start to work if they are tried!!). --alen the Lisa slayer (it's a long story) ...!seismo!esosun!cogen!alen
brian@ncrcan.UUCP (10/20/87)
In article <666@portofix.liu.se> kjepo@portofix.liu.se (Kjell Post) writes: >A little trick question for you all: what's happening here? > > % cat > \* > date > ^D > % chmod +x \* > % \* > Tue Oct 13 03:13:08 MET 1987 > % > % cat > + > date > ^D > % chmod +x + > % + > $ -- entered Bourne-shell > This one's easy. When the cshell goes to exec a program, it checks to see if it has a valid magic number and uses fork/exec if so. Otherwise it checks to see if the first character is '#' and if so assumes that the file is a cshell script and executes it directly. If not, the cshell assumes that the file is a Bourne shell script and passes the file off to the Bourne shell to be executed. The file '+' looks like a Bourne shell script to the cshell, and so the chell says: /bin/sh + the '+' being the filename the cshell wants to execute. Now in the Bourne shell, one can turn on or off certain options using - or + in front of the option letters. Your example above also produces the same results if you use '-' instead of '+'. 'sh -' is documented, 'sh +' is not. So the Bourne shell thinks you want to turn off some option, but you just didn't supply the option, or possibly this is the explicit opposite to 'sh -' (I haven't looked up the source, and especially don't want to dive into the horrendouse Bourne Shell code). If 'sh -' means execute the .profile, maybe 'sh +' explicitly means not to? Also, you can use any number of '+'s and '-'s, and you will end up in the Bourne shell. This may add more weight to the possibility of an opposite to 'sh -', as it seems to indicate how the command line in 'sh' in parsed for arguments. Anyone else care to comment more on this. -- +-------------------+--------------------------------------------------------+ | Brian Onn | UUCP:..!{uunet!mnetor, watmath!utai}!lsuc!ncrcan!brian | | NCR Canada Ltd. | INTERNET: brian@ncrcan.UUCP | +-------------------+--------------------------------------------------------+
davidsen@steinmetz.steinmetz.UUCP (William E. Davidsen Jr) (10/20/87)
In article <666@portofix.liu.se> kjepo@portofix.liu.se (Kjell Post) writes: |A little trick question for you all: what's happening here? ================ stuff ================ | % cat > + | date | ^D | % chmod +x + | % + | $ -- entered Bourne-shell I have only been able to get this to happen on SysV systems with csh. Moreover it works as expected if I use "./+" instead. The problem appears to be due to the csh stripping the + as an option somehow. When it sees the leading + it identifies the file as a command file, starts to setup an exec call, then treats the + as an option rather than a filename and strips it. Now I have a question: why are you doing this? -- bill davidsen (wedu@ge-crd.arpa) {uunet | philabs | seismo}!steinmetz!crdos1!davidsen "Stupidity, like virtue, is its own reward" -me
tel@moby.UUCP (Tom Lowe) (10/20/87)
In article <666@portofix.liu.se>, kjepo@portofix.liu.se (Kjell Post) writes: > A little trick question for you all: what's happening here? > [...] > % chmod +x + > % + > $ -- entered Bourne-shell I didn't have any problem...I got date and time! -- Tom Lowe {rutgers,gatech,huscb,burdvax,ihnp4,cbosgd}!psuvax1!moby!tel AT&T National Systems Support Center, S. Plainfield, NJ (1-800-922-0354) Please call only if you have an AT&T computer under Warranty or if you have an AT&T Maintenance Contract on your equipment.
brianc@cognos.uucp (Brian Campbell) (10/20/87)
In article <666@portofix.liu.se> kjepo@portofix.liu.se (Kjell Post) writes:
! % cat > +
! date
! ^D
! % chmod +x +
! % +
! $ -- entered Bourne-shell
Same thing happens to me -- on 4.2BSD and XENIX 2.1.3. A rehash
doesn't help any, but typing ./+ does execute the script as expected.
Maybe + is some weird builtin alias? I'd sure like to know what's going
on ...
--
Brian Campbell uucp: decvax!utzoo!dciem!nrcaer!cognos!brianc
Cognos Incorporated mail: POB 9707, 3755 Riverside Drive, Ottawa, K1G 3Z4
(613) 738-1440 fido: (613) 731-2945 300/1200, sysop@1:163/8
allbery@ncoast.UUCP (Brandon Allbery) (10/23/87)
As quoted from <666@portofix.liu.se> by kjepo@portofix.liu.se (Kjell Post): +--------------- | A little trick question for you all: what's happening here? | | % cat > + | date | ^D | % chmod +x + | % + | $ -- entered Bourne-shell +--------------- Is this on System V with a csh, or a Sun or other BSD system with the System V sh? The System V sh treats + like - for setting flags; as a result, when execvp() does its thing you get sh + which will start an interactive shell. -- Brandon S. Allbery necntc!ncoast!allbery@harvard.harvard.edu {{harvard,mit-eddie}!necntc,well!hoptoad,sun!mandrill!hal}!ncoast!allbery