Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: how to refer to basename of $0
On Fri, 29 Jul 2011, Tomasz Moskal wrote:
On Thu, 2011-07-28 at 21:04 -0700, Bart Schaefer wrote:
On Jul 28, 9:39pm, TJ Luoma wrote:
}
} Is it even possible to set NAME in .zsh* (and have it return
} 'test.zsh' or are they called too early in the process?
This is sounding awfully familiar. Oh, it was on zsh-workers, where
some of the -users crowd would not have seen it.
Starts here:
http://www.zsh.org/mla/workers/2011/msg00159.html
Interesting branch begins here:
http://www.zsh.org/mla/workers/2011/msg00163.html
Particularly:
http://www.zsh.org/mla/workers//2011/msg00172.html
Thanks for the links, but I am still baffled - basename $0 is
working here without any problems:
% cat ~/.zshenv
unsetopt function_argzero
name=`basename $0`
% cat ./foo
#!/bin/zsh
. ~/.zshenv
echo $name
exit 0
The point wasn't quite the same (didn't involve "source"-ing .zshenv).
$0 doesn't work if used inside startup files (.zshenv/.zshrc/.zprofile).
When you source it manually, it's not treated specially.
Just wanted to note that the '%x' that I pointed out does work, though:
## as the first line of .zshenv (so, will be run when starting zsh)
$ sed 1q ~/.zshenv
echo in .zshenv 0=$0 %x=${(%):-%x}
## results in:
$ zsh
in .zshenv 0=zsh %x=/home/bhaskell/.zshenv
--
Best,
Ben
Messages sorted by:
Reverse Date,
Date,
Thread,
Author