summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Fiddaman <omnios@citrus-it.co.uk>2021-02-12 14:56:46 +0000
committerAndy Fiddaman <omnios@citrus-it.co.uk>2021-02-28 15:19:50 +0000
commit718fc4ac1dfcd860e967fb444c831507f97cd300 (patch)
tree97b77eff407f74620f702fcc155847619f9b1b05
parent3be0d903330def6576e70a1a8a028f5828c9ea45 (diff)
downloadillumos-joyent-718fc4ac1dfcd860e967fb444c831507f97cd300.tar.gz
13512 ksh's >; is not reliable with `-c'
Reviewed by: Toomas Soome <tsoome@me.com> Reviewed by: Gordon Ross <gordon.w.ross@gmail.com> Reviewed by: Rich Lowe <richlowe@richlowe.net> Approved by: Dan McDonald <danmcd@joyent.com>
-rw-r--r--usr/src/contrib/ast/src/cmd/ksh93/sh/main.c7
-rwxr-xr-xusr/src/contrib/ast/src/cmd/ksh93/tests/io.sh14
2 files changed, 14 insertions, 7 deletions
diff --git a/usr/src/contrib/ast/src/cmd/ksh93/sh/main.c b/usr/src/contrib/ast/src/cmd/ksh93/sh/main.c
index e5fdc550b7..e334072821 100644
--- a/usr/src/contrib/ast/src/cmd/ksh93/sh/main.c
+++ b/usr/src/contrib/ast/src/cmd/ksh93/sh/main.c
@@ -580,13 +580,6 @@ static void exfile(register Shell_t *shp, register Sfio_t *iop,register int fno)
if(t)
{
execflags = sh_state(SH_ERREXIT)|sh_state(SH_INTERACTIVE);
- /* The last command may not have to fork */
- if(!sh_isstate(SH_PROFILE) && sh_isoption(SH_CFLAG) &&
- (fno<0 || !(shp->fdstatus[fno]&(IOTTY|IONOSEEK)))
- && !sfreserve(iop,0,0))
- {
- execflags |= sh_state(SH_NOFORK);
- }
shp->st.execbrk = 0;
sh_exec(t,execflags);
if(shp->forked)
diff --git a/usr/src/contrib/ast/src/cmd/ksh93/tests/io.sh b/usr/src/contrib/ast/src/cmd/ksh93/tests/io.sh
index c4a5fdf6ac..819ce7ba86 100755
--- a/usr/src/contrib/ast/src/cmd/ksh93/tests/io.sh
+++ b/usr/src/contrib/ast/src/cmd/ksh93/tests/io.sh
@@ -496,4 +496,18 @@ done {n}< /dev/null
n=$( exec {n}< /dev/null; print -r -- $n)
[[ -r /dev/fd/$n ]] && err_exit "file descriptor n=$n left open after subshell"
+# ==========
+# https://github.com/att/ast/issues/9
+tf=`mktemp`
+echo foo bar > $tf
+$SHELL -c 'echo xxx 1<>; '$tf
+actual=$(cat $tf)
+expect="xxx"
+[[ "$actual" = "$expect" ]] || err_exit "<>; does not truncate files - $expect - $actual"
+rm -f $tf
+
+cp /dev/null $tf
+$SHELL -c '{ echo "Foo"; echo "bar"; uname; } >; '$tf
+[[ -s "$tf" ]] || err_exit ">; does not work with -c"
+rm -f $tf
exit $((Errors<125?Errors:125))