Skip to main content
The 2024 Developer Survey results are live! See the results
added 27 characters in body
Source Link

I have an alias rm='/bin/rm -i' and I know that if I type "rm" filename in the command line, the alias, will be ignored somehow and the normal rm command without the -i flag will be called, but I don't understand why this works.

I don't understand why "rm" works at all, considering...

Enclosing characters in double quotes (‘"’) preserves the literal value of all characters within the quotes, with the exception of ‘$’, ‘`’, ‘\’, and, when history expansion is enabled, ‘!’. - [gnu.org][1]

... but it does work somehow. And it ignores my alias. How does this work?

Furthermore, I see these alias-ignoring command invocations in my organization's Korn shell scripts sometimes. But that's unnecessary, right? Because Korn shell scripts don't have access to shell-level aliases anyway?

[1]: https://www.gnu.org/software/bash/manual/html_node/Double-Quotes.html#:~:text=Enclosing%20characters%20in%20double%20quotes,POSIX%20Mode)%2C%20the%20%27%20!

I have an alias rm='/bin/rm -i' and I know that if I type "rm" filename in the command line, the alias, the normal rm command without the -i flag will be called, but I don't understand why this works.

I don't understand why "rm" works at all, considering...

Enclosing characters in double quotes (‘"’) preserves the literal value of all characters within the quotes, with the exception of ‘$’, ‘`’, ‘\’, and, when history expansion is enabled, ‘!’. - [gnu.org][1]

... but it does work somehow. And it ignores my alias. How does this work?

Furthermore, I see these alias-ignoring command invocations in my organization's Korn shell scripts sometimes. But that's unnecessary, right? Because Korn shell scripts don't have access to shell-level aliases anyway?

[1]: https://www.gnu.org/software/bash/manual/html_node/Double-Quotes.html#:~:text=Enclosing%20characters%20in%20double%20quotes,POSIX%20Mode)%2C%20the%20%27%20!

I have an alias rm='/bin/rm -i' and I know that if I type "rm" filename in the command line, the alias will be ignored somehow and the normal rm command without the -i flag will be called, but I don't understand why this works.

I don't understand why "rm" works at all, considering...

Enclosing characters in double quotes (‘"’) preserves the literal value of all characters within the quotes, with the exception of ‘$’, ‘`’, ‘\’, and, when history expansion is enabled, ‘!’. - [gnu.org][1]

... but it does work somehow. And it ignores my alias. How does this work?

Furthermore, I see these alias-ignoring command invocations in my organization's Korn shell scripts sometimes. But that's unnecessary, right? Because Korn shell scripts don't have access to shell-level aliases anyway?

[1]: https://www.gnu.org/software/bash/manual/html_node/Double-Quotes.html#:~:text=Enclosing%20characters%20in%20double%20quotes,POSIX%20Mode)%2C%20the%20%27%20!

Source Link

Why does enclosing a command in double quotes affect aliases?

I have an alias rm='/bin/rm -i' and I know that if I type "rm" filename in the command line, the alias, the normal rm command without the -i flag will be called, but I don't understand why this works.

I don't understand why "rm" works at all, considering...

Enclosing characters in double quotes (‘"’) preserves the literal value of all characters within the quotes, with the exception of ‘$’, ‘`’, ‘\’, and, when history expansion is enabled, ‘!’. - [gnu.org][1]

... but it does work somehow. And it ignores my alias. How does this work?

Furthermore, I see these alias-ignoring command invocations in my organization's Korn shell scripts sometimes. But that's unnecessary, right? Because Korn shell scripts don't have access to shell-level aliases anyway?

[1]: https://www.gnu.org/software/bash/manual/html_node/Double-Quotes.html#:~:text=Enclosing%20characters%20in%20double%20quotes,POSIX%20Mode)%2C%20the%20%27%20!