Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: How to use precommand modifiers `-` ?



 ❦ 13 mai 2021 13:04 +02, Roman Perepelitsa:

>> ```-
>>
>> The command is executed with a ‘-’ prepended to its argv[0] string.
>>
>> ```
>>
>> As a non-native speaker of English, I'm confused about this.
>> Can anyone give me some examples?
>
> Here's an example:
>
>     % zsh -fc 'print -r -- $0'
>     zsh
>
>     % - zsh -fc 'print -r -- $0'
>     -zsh
>
> Here $0 gives us argv[0].

To complete your answer, this is used by shells to know if they should
use a login session or not. Some shells, including Zsh, can also take an
option for that (-l), but it's not an universal option, hence the use of
this convention: either the target understands it and it works as
expected or it does not and it is harmless. I don't think there is any
other purpose.
-- 
Habit is habit, and not to be flung out of the window by any man, but coaxed
down-stairs a step at a time.
		-- Mark Twain, "Pudd'nhead Wilson's Calendar




Messages sorted by: Reverse Date, Date, Thread, Author