zsh-users
 help / color / mirror / Atom feed
* How to use precommand modifiers `-` ?
@ 2021-05-13  9:48 andme
  2021-05-13 11:04 ` Roman Perepelitsa
  0 siblings, 1 reply; 3+ messages in thread
From: andme @ 2021-05-13  9:48 UTC (permalink / raw)
  To: zsh-users

[-- Attachment #1: Type: text/plain, Size: 189 bytes --]

```-

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?


Thanks

[-- Attachment #2: Type: text/html, Size: 1704 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: How to use precommand modifiers `-` ?
  2021-05-13  9:48 How to use precommand modifiers `-` ? andme
@ 2021-05-13 11:04 ` Roman Perepelitsa
  2021-05-13 12:00   ` Vincent Bernat
  0 siblings, 1 reply; 3+ messages in thread
From: Roman Perepelitsa @ 2021-05-13 11:04 UTC (permalink / raw)
  To: andme; +Cc: zsh-users

On Thu, May 13, 2021 at 12:56 PM andme <15991987063@163.com> wrote:
>
> ```-
>
> 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].

Roman.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: How to use precommand modifiers `-` ?
  2021-05-13 11:04 ` Roman Perepelitsa
@ 2021-05-13 12:00   ` Vincent Bernat
  0 siblings, 0 replies; 3+ messages in thread
From: Vincent Bernat @ 2021-05-13 12:00 UTC (permalink / raw)
  To: Roman Perepelitsa; +Cc: andme, zsh-users

 ❦ 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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-05-13 12:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-13  9:48 How to use precommand modifiers `-` ? andme
2021-05-13 11:04 ` Roman Perepelitsa
2021-05-13 12:00   ` Vincent Bernat

zsh-users

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://inbox.vuxu.org/zsh-users

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 zsh-users zsh-users/ http://inbox.vuxu.org/zsh-users \
		zsh-users@zsh.org
	public-inbox-index zsh-users

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.zsh.users


code repositories for the project(s) associated with this inbox:

	https://git.vuxu.org/mirror/zsh/

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git