Today I happened to press ' after ls
So the command is ls'
> ls' quote> ls' zsh: command not found: lsnls >
Can someone tell me, what is the ls quote thing?
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
Since you opened a quotation ' and pressed enter, the shell is wanting you to close the quote. The quote> prompt is simply a visual indication of such.
This is so that you can pass multi-line arguments to programs.
For example:
$ echo 'hi quote> there' hi there
Since you typed ls'Enterls'Enter, this is the equivalent to trying to run a command called lsnls (a command with a newline character in the middle of it), which doesn’t exist and so the shell gave you an error.
Method 2
That quote> is the $PS2 (aka $PROMPT2 in zsh) prompt, the secondary prompt string.
The primary prompt string ($PS1 / $PROMPT), > it seems in your case, is the one that invites you to enter a command. The secondary command is the one that invites you to continue and finish your command.
It’s displayed after you’ve pressed Enter while the command was not finished yet.
In zsh, the default value of $PS2 is %_> , where %_ is (documented under Prompt Expansion / Shell State):
%_
The status of the parser, i.e. the shell constructs (like
ifandfor) that have been started on the command line. If given an integer number that many strings will be printed; zero or negative or no integer means print as many as there are. This is most useful in promptsPS2for continuation lines andPS4for debugging with theXTRACEoption; in the latter case it will also work non-interactively.
For instance, if I enter:
my-PS1-prompt> (while true; do for i in "${var-qwe
subsh while for dquote braceparam>
The shell tells me I still need to close that ${...} brace parameter expansion, the "..." double quote, finish the for and while statement and close the subshell before that command is complete and shell can start running it.
In your case, it tells you you need to close that '...' single-quoted string. Once you do, it tries to run the corresponding command and fails as there’s no ls<newline>ls command on your system.
Note that instead of pressing Enter, you could have pressed Escape, Enter (which on some terminals you can also enter as Alt + Enter), or Ctrl + V, Ctrl + J for a literal newline character (aka ^J) to be entered in the editing buffer instead of the current line to be submitted to the shell. In that case, you won’t see the secondary prompt, and you’ll be able to move the cursor back to the first line.
Beside $PS1 and $PS2, there’s also $PS3 (aka $PROMPT3), used in select statements, $PS4 (aka $PROMPT4) used for xtrace debugging output, $RPS1 ($RPROMP) and $RPS2 ($RPOMPT2) like $PS1/$PS2 except they are printed on the right side of the screen.
$PS1,2,3,4 are from the Korn shell, while %x special sequences are from csh (greatly expanded by zsh). POSIX specifies all but PS3 (as it doesn’t specify ksh‘s select statement), but not the %x sequences.
tcsh had $prompt and $rprompt which inspired zsh‘s $RPS1 / $PRS2.
The bash shell chose a different (and unfortunate) syntax for its special sequences in its $PSx prompts using instead of % and different and incompatible letters from the ones in tcsh/zsh. %_ is zsh-specific.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0