[git commit] ash: explain EXP_REDIR and why we (dont) glob redir filenames

Denys Vlasenko vda.linux at googlemail.com
Mon Oct 24 19:12:33 UTC 2016


commit: https://git.busybox.net/busybox/commit/?id=db74c6caedf752623820cd09f7fbeaf4152e1de8
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master

Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 shell/ash.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/shell/ash.c b/shell/ash.c
index c9d39b8..d9595bb 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -5545,6 +5545,17 @@ ash_arith(const char *s)
 #define EXP_TILDE       0x2     /* do normal tilde expansion */
 #define EXP_VARTILDE    0x4     /* expand tildes in an assignment */
 #define EXP_REDIR       0x8     /* file glob for a redirection (1 match only) */
+/* ^^^^^^^^^^^^^^ this is meant to support constructs such as "cmd >file*.txt"
+ * POSIX says for this case:
+ *  Pathname expansion shall not be performed on the word by a
+ *  non-interactive shell; an interactive shell may perform it, but shall
+ *  do so only when the expansion would result in one word.
+ * Currently, our code complies to the above rule by never globbing
+ * redirection filenames.
+ * Bash performs globbing, unless it is non-interactive and in POSIX mode.
+ * (this means that on a typical Linux distro, bash almost always
+ * performs globbing, and thus diverges from what we do).
+ */
 #define EXP_CASE        0x10    /* keeps quotes around for CASE pattern */
 #define EXP_QPAT        0x20    /* pattern in quoted parameter expansion */
 #define EXP_VARTILDE2   0x40    /* expand tildes after colons only */


More information about the busybox-cvs mailing list