Re: Different meanings of $0 under the same operating system by Anonymous Monk on Nov 03, 2009 at 11:00 UTC |
That is no surprise if the post meant to show one. Try with (symbolic|hard) link (exectute the link created afterwords). | [reply] |
Re: Different meanings of $0 under the same operating system by JavaFan (Parson) on Nov 03, 2009 at 11:28 UTC |
| [reply] [d/l] |
|
Well, yes, of course I could have written a shorter program like yours.
In that case the program would totally miss the output when run by Nautilus without a terminal open, wouldn't it? Just try to run your shorter program without a terminal.
| [reply] |
|
| [reply] [d/l] |
|
|
|
Re: Different meanings of $0 under the same operating system by Anonymous Monk on Nov 03, 2009 at 13:42 UTC |
| [reply] [d/l] |
|
...except for some primitive operating systems out there that use other characters than '/' to separate path elements.
--
Time flies when you don't know what you're doing
| [reply] |
Re: Different meanings of $0 under the same operating system by ikegami (Saint) on Nov 03, 2009 at 15:21 UTC |
| [reply] [d/l] [select] |
Re: Different meanings of $0 under the same operating system by MidLifeXis (Priest) on Nov 03, 2009 at 15:45 UTC |
The same exists for C (argv[0]), shell ($0), and many other languages. Under some OSen and languages, you can even change the name of the program in the process list by modifying $0 to be what you want.
| [reply] |
Re: Different meanings of $0 under the same operating system by Bloodnok (Priest) on Nov 03, 2009 at 16:19 UTC |
...all of which can be summarised as: $0 represents the path by which *NIX locates the script
Furthermore, there is yet a 4th possibility - normally only noticed under one of the std *NIX shells whereby, if a script is 'dot'ted or 'source'ed, $0 is the name of the shell in which the 'dot'/'source' command is run - the perl equivalent of which is to do knowthyself from another script.
A user level that continues to overstate my experience :-))
| [reply] [d/l] [select] |
|
...all of which can be summarised as: $0 represents the path by which *NIX locates the script
I agree. Maybe we should promote a change in the perlvar definition of $0 I quoted at the very beginning of this node ("the name of the program being executed")?
| [reply] |
|
| [reply] [d/l] |
|
Ahh, but it is ... since, when used as a file name, '-' is an alternative id for stdin - witness most of the *NIX filter commands e.g. sort, join et al
A user level that continues to overstate my experience :-))
| [reply] |
|
|