Tag Info

New answers tagged

10

Adding on to Miroslav's answer: echo $- prints options of the current shell (without - prefix). 1 and 2 are additional unrelated tokens. This means that these are the options, for each machine respectively. imsBEl himBH I have researched the meaning of each flag and compiled the meanings below, with minor paraphrasing. -i If the -i option ...


3

To expand on the existing answers, try echo "${-1}" and echo "${-2}" - you'll get a "Bad substitution" error because rather than using -1 as a variable name the hyphen is used to substitute a value if the variable name before it is undefined. For example: $ unset foo $ echo "${foo-bar}" bar $ foo=test $ echo "${foo-bar}" test


17

POSIX defined $- as: - (Hyphen.) Expands to the current option flags (the single-letter option names concatenated into a string) as specified on invocation, by the set special built-in command, or implicitly by the shell. So $- can be different base on your shell or how you invoke it. 1 or 2 are separated token here. When the shell see ...


18

echo $- prints options of the current shell (without - prefix). 1 and 2 are additional unrelated tokens.



Top 50 recent answers are included