← Commit list

8c68ae841

Denys Vlasenko
Denys Vlasenko
2021-09-08
SUCCESS Duration: 153s

Subject

ash: parser: Fix alias expansion after heredoc or newlines

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

shell/ash.c+5 -2
@@ -13265,10 +13265,14 @@ readtoken(void)
if (kwd & CHKNL) {
while (t == TNL) {
parseheredoc();
+ checkkwd = 0;
t = xxreadtoken();
}
}
+ kwd |= checkkwd;
+ checkkwd = 0;
+
if (t != TWORD || quoteflag) {
goto out;
}
@@ -13287,7 +13291,7 @@ readtoken(void)
}
}
- if (checkkwd & CHKALIAS) {
+ if (kwd & CHKALIAS) {
#if ENABLE_ASH_ALIAS
struct alias *ap;
ap = lookupalias(wordtext, 1);
@@ -13300,7 +13304,6 @@ readtoken(void)
#endif
}
out:
- checkkwd = 0;
#if DEBUG
if (!alreadyseen)
TRACE(("token '%s' %s\n", tokname_array[t], t == TWORD ? wordtext : ""));
shell/ash_test/ash-alias/alias_brace.right+1 -0
@@ -0,0 +1 @@
+Ok
shell/ash_test/ash-alias/alias_brace.tests+16 -0
@@ -0,0 +1,16 @@
+# Note: bash would need:
+#shopt -s expand_aliases
+# to enable aliases in non-interactive mode
+alias BEGIN={ END=}
+BEGIN
+ cat <<- EOF > /dev/null
+ $(:)
+ EOF
+END
+
+: <<- EOF &&
+ $(:)
+EOF
+BEGIN
+ echo Ok
+END
shell/ash_test/ash-alias/alias_case.right+1 -0
@@ -0,0 +1 @@
+Ok
shell/ash_test/ash-alias/alias_case.tests+8 -0
@@ -0,0 +1,8 @@
+# Note: bash would need:
+#shopt -s expand_aliases
+# to enable aliases in non-interactive mode
+alias a="case x in " b=x
+a
+b) echo BAD;;
+*) echo Ok;;
+esac