From: Rusty Bird <rustybird@openmailbox.org>
To: dash@vger.kernel.org
Cc: Jilles Tjoelker <jilles@stack.nl>
Subject: Re: Ignored alias inside for loop
Date: Sun, 26 Jul 2015 16:09:12 +0000 [thread overview]
Message-ID: <55B50628.5090901@openmailbox.org> (raw)
In-Reply-To: <20150726152602.GA4346@stack.nl>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
Hi Jilles,
> Aliases are expanded during parsing, not during execution (like
> functions are). The for loop is parsed completely before it is
> executed.
Ah, what confused me was that I wrongly remembered it working inside
an if (instead of for) block. But looking again now, only the alias
*definition* was inside.
> Using a function instead of an alias, or using eval will do what
> you want.
Do you mean replacing the line with: eval "alias foobarbaz='echo ok'"
That doesn't seem to work either (in dash or bash).
> Note that some parts of the parse/execute split are not specified
> by POSIX. In particular, ksh93 and the real Bourne shell parse dot
> scripts completely before executing anything, while most other
> shells parse as needed. Example: given the file alias1.sh below:
>
> alias foobarbaz='echo ok' foobarbaz
>
> The result is ok when running dash -c '. ./alias1.sh' but a
> command not found error message when running ksh93 -c '.
> ./alias1.sh'.
>
> Similarly, a string as passed to the -c option or eval or trap
> builtins may or may not be parsed fully before execution.
Interesting, thanks!
Rusty
-----BEGIN PGP SIGNATURE-----
iQJ8BAEBCgBmBQJVtQYoXxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25zLm9w
ZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXQ4NEI1OUJDRkM2MkIxMjlGRTFCMDZEMDQ0
NjlENzhGNDdBQUYyQURGAAoJEEadePR6ryrfCwUP/AtBWQpOEajCsghiYrkDmVpS
FuDMMo9s+uUTwJ6zrVviuj4cCfaigDBr1hlmc5ETjIMxbqgXYmG0o1GDkUvohKDR
4apjVRXATe8Xuia+E94rZTqv1iAv+udCD1BVhH9SB0Hbc9Jf9bxAqY6JI+GxoPRc
ea4tGDAPdPl9NJ69pPXP5AuDplqQOuap8BKzG00bu422z4CkIorvsg0W4+Ya+k+j
KZetjxj6N8vF17gOLpWNuxtJKbDEokNhHCGuf3hS1+7SEibJKYhb3GkyDGJ5EPYv
m3AocOlfSEuhZR8Dt5bK4gPNByrxl03PabBGmXVQaBzqjn+vIfykcuESXSHcl5SA
02FVY3pWAZKPCGWnG2JcGZpn6jQJQt5fNtM5ooixmzvFM/f0ItOL3EFKwHzIZxh1
ic+qIZcO8RrwfKktM3vytZ3fkSAVWJMcflj34+ce5A/LyfdrrqAkJGI3AbEul+Q6
mQoYZGBL7Uq2tgBWNveWzAByaewiW/+nlLhUXQh69L3X1cjkkrULGDTSaV+EYZ+z
mJP3qQcAB2DVnr757XgIh4kkDX8MDY4ZYVB+8ApgImUnBoklSSJeWXnBt+KwZgk7
Rok5FxIde3OgyYB9tjzDF/EAZXKTKNLrXFkhhat9j2c8+8VptVNcw77HP2bbcgOE
78H1zJW4UF8ntB5SGLTd
=qogf
-----END PGP SIGNATURE-----
next prev parent reply other threads:[~2015-07-26 16:10 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-26 9:23 Ignored alias inside for loop Rusty Bird
2015-07-26 15:26 ` Jilles Tjoelker
2015-07-26 16:09 ` Rusty Bird [this message]
2015-07-26 18:41 ` Jilles Tjoelker
2015-07-27 8:24 ` Seb
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=55B50628.5090901@openmailbox.org \
--to=rustybird@openmailbox.org \
--cc=dash@vger.kernel.org \
--cc=jilles@stack.nl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.