Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the use case for this zsh precommand modifier '-'

Tags:

zsh

So in zsh; do this

$ - ls /some/non/existent/directory/blah/blah/blah

gives you

-ls: /some/non/existent/directory/blah/blah/blah: No such file or directory

Documentation:

http://zsh.sourceforge.net/Doc/Release/Shell-Grammar.html#Precommand-Modifiers


What reasonable use case does this actualy have?

like image 798
WTFBBQHAX Avatar asked Nov 03 '25 23:11

WTFBBQHAX


1 Answers

From zshmisc(1):

-      The  command  is  executed  with  a `-' prepended to its argv[0]
          string.

Invoking a shell with a - prepended to its name (-sh, -bash, -zsh) is an old convention for indicating the shell should start a login session. It's up to the program itself to decide if such an invocation should mean anything. Most programs, like ls, ignore how they are called.

like image 110
chepner Avatar answered Nov 07 '25 15:11

chepner