Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

499
Vistas
If bash aliases cannot accept arguments, why do these aliases work?

As a naive noob, I created several bash aliases intended to accept arguments, and they work exactly as intended. I tried to make a few more such aliases, however, and these would not work as intended.

This problem led me here, where I learned that bash aliases do not accept arguments. Instead, you must create a function. For example see here or here.

So, assuming the "bash aliases do not accept arguments" consensus is correct, why do all of these work?

alias pacss='pacman -Ss '
alias pacs='sudo pacman -S '
alias yausnc='yaourt -S --noconfirm '

When I say these "work" I mean that, e.g., typing 'pacs package' results in prompting me for password, prompting for confirmation, then retrieving and installing package.

So, why do these aliases work? Are the terms they accept not technically considered 'arguments'? Is it an idiosyncrasy of Arch (or Manjaro, which I am using)? A hole in the space-time continuum?

Any clarification shall be appreciated.

EDIT: Thanks for the answers explaining these are not calling for arguments. I don't quite understand how my first examples are different from the following attempted alias, which does not work:

alias lping='ping 192.168.1.'

This fails because ping executes without appending the number I type. My intent was to be able to enter e.g. lping 123 and have bash execute "ping 192.168.1.123" but instead it says "unknown host 192.168.1."

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

No, the terms they "accept" aren't called "arguments".
Bash aliases are just text replacements.
That is, when you write

pacs

bash replaces that with

sudo pacman -S 

and when you write

pacs package

bash replaces that with

sudo pacman -S package

In other words, the arguments aren't passed to the alias – the characters after the alias are just appended to whatever the alias expands to.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda