sed: reject 's///e' in --posix mode

's///e' modifier is a gnu extension - reject it in --posix mode.

* sed/compile.c: (mark_subst_opt): Exit upon 's///e' in posix mode.
* testsuite/posix-mode-s.sh: Adjust tests accordingly.
This commit is contained in:
Assaf Gordon committed 2016-08-08 20:32:16 -04:00
1 parent b18d64d802
commit ab0cfea35c
2 files changed
+8 -3

No files matched your search

+2
View File
@@ -603,6 +603,8 @@ mark_subst_opts (struct subst *cmd)
break;
case 'e':
if (posixicity == POSIXLY_BASIC)
bad_prog(_(UNKNOWN_S_OPT));
cmd->eval = true;
break;
+6 -3
View File
@@ -19,7 +19,6 @@
print_ver_ sed
fail=0
unset POSIXLY_CORRECT
cat <<\EOF >exp-err || framework_failure_
sed: -e expression #1, char 7: unknown option to `s'
@@ -48,9 +47,13 @@ printf "hello\n" >exp-gnu-e || framework_failure_
sed 's/./printf hello/e' in1 > out-gnu-e || fail=1
compare exp-gnu-e out-gnu-e || fail=1
#TODO: this is not supposed to work in posix mode
#returns_ 1 sed --posix 's/./printf hello/e' in1 2>err-posix-e || fail=1
# s///e rejected in POSIX mode
cat <<\EOF >exp-err-psx-e || framework_failure_
sed: -e expression #1, char 10: unknown option to `s'
EOF
returns_ 1 sed --posix 's/./echo/e' in1 2>err-posix-e || fail=1
compare_ exp-err-psx-e err-posix-e || fail=1
# substitution special commands (e.g \l \L \U \u \E).