Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: How to use precommand modifiers `-` ?
- X-seq: zsh-users 26733
- From: Vincent Bernat <bernat@xxxxxxxx>
- To: Roman Perepelitsa <roman.perepelitsa@xxxxxxxxx>
- Cc: andme <15991987063@xxxxxxx>, zsh-users <zsh-users@xxxxxxx>
- Subject: Re: How to use precommand modifiers `-` ?
- Date: Thu, 13 May 2021 14:00:43 +0200
- Archived-at: <https://zsh.org/users/26733>
- In-reply-to: <CAN=4vMpXh-9Ja9tGJ_T8pgoX7Ehxm5FjNcqJW2AXZ2kOgHaX6A@mail.gmail.com> (Roman Perepelitsa's message of "Thu, 13 May 2021 13:04:04 +0200")
- List-id: <zsh-users.zsh.org>
- References: <63c609c4.4d5f.17965205c4c.Coremail.15991987063@163.com> <CAN=4vMpXh-9Ja9tGJ_T8pgoX7Ehxm5FjNcqJW2AXZ2kOgHaX6A@mail.gmail.com>
❦ 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