[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: An alias named `done` breaks for loops
From: |
Ilkka Virta |
Subject: |
Re: An alias named `done` breaks for loops |
Date: |
Mon, 16 Aug 2021 15:11:05 +0300 |
On Sun, Aug 15, 2021 at 2:00 AM George Nachman <gnachman@llamas.org> wrote:
> Defining an alias named `done` breaks parsing a for loop that does not have
> an `in word` clause.
>
alias done=""
>
Works for me:
$ set -- a b c
$ alias done='echo hi; done'
$ for x do done
hi
hi
hi
Not that I think it's a good idea to use aliases to mess with the syntax,
or that I
could see what use that empty alias could possibly have.
The way aliases work is kinda unclean to begin with, so if you want to avoid
shooting yourself in the foot with them, then don't use them. For functions,
this seems already impossible:
$ done() { echo 'hello?'; }
bash: syntax error near unexpected token `('
$ \done() { echo 'hello?'; }
bash: `\done': not a valid identifier