Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are shell aliases POSIX compliant?

Tags:

alias

shell

posix

I am writing a utility which lets you set shell aliases persistently.

I have it in my head that unix shell aliases are POSIX compliant, but I can't remember where I heard this and my google fu has not yielded any definitive answer.

Most of my experience is with zsh and bash.

Is it safe to assume that if I write aliases in the format of specified by both bash and zsh, that I'll be able to port this format over to other shells?

like image 844
mvanveen Avatar asked Jan 28 '12 10:01

mvanveen


People also ask

Which shells are POSIX compliant?

Some popular shell languages are POSIX-compliant (Bash, Korn shell), but even they offer additional non-POSIX features which will not always function on other shells. The commands test expression is identical to the command [expression] . In fact, many sources recommend using the brackets for better readability.

Is bash POSIX compatible?

You can use POSIX standard in many shells such as, dash , bash , ksh , mksh , yash , zsh , etc. You need to be aware that each shell has its own commands and options or different options top of the POSIX specification.

What is a POSIX like shell?

POSIX Shell is a command line shell for computer operating system which was introduced by IEEE Computer Society. POSIX stands for Portable Operating System Interface. POSIX Shell is based on the standard defined in Portable Operating System Interface (POSIX) – IEEE P1003.

Does Korn shell support aliases?

The Korn shell, or POSIX shell, allows you to create aliases to customize commands. The alias command defines a word of the form Name=String as an alias. When you use an alias as the first word of a command line, the Korn shell checks to see if it is already processing an alias with the same name.


1 Answers

alias (and unalias) are indeed in POSIX.

See also alias substitution and alias names for how they are supposed to be implemented.

like image 161
Mat Avatar answered Oct 02 '22 12:10

Mat