Skip to content

Commit 56df453

Browse files
committed
spec: Test for internal fds to be properly shifted away when requested
Signed-off-by: Andrii Sultanov <[email protected]>
1 parent 0b62938 commit 56df453

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

spec/builtin-eval-source.test.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,19 @@ echo status=$?
348348
## stdout: status=1
349349
## OK dash/zsh/mksh stdout: status=0
350350

351+
#### source'd fd should be shifted when requested by the script
352+
cd $TMP
353+
cat >out.osh <<EOF
354+
exec 10>out
355+
echo hello>&10
356+
cat out
357+
EOF
358+
. ./out.osh
359+
## stdout: hello
360+
## N-I dash/zsh status: 127
361+
## N-I dash/zsh STDOUT:
362+
## END
363+
351364
#### sourcing along PATH should ignore directories
352365

353366
mkdir -p _tmp/shell

spec/interactive.test.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,17 @@ $SH --rcfile myrc -i -c 'show-shell-state main'
323323
# comparisons.
324324
# The --details flag is useful
325325

326+
#### rc file's fd is moved out of the way when requested by the user
327+
cat >$TMP/oshrc <<EOF
328+
exec 10>out
329+
echo hello>&10
330+
cat out
331+
EOF
332+
$SH --rcfile $TMP/oshrc -i -c 'echo hello'
333+
## STDOUT:
334+
hello
335+
hello
336+
## END
326337

327338
#### HISTFILE is written in interactive shell
328339

spec/sh-usage.test.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,20 @@ status=0
168168
## N-I bash/dash/mksh/zsh STDOUT:
169169
## END
170170

171+
#### eval'd fd is moved out of the way when requested by the script
172+
case $SH in bash|dash|mksh|zsh) exit ;; esac
173+
cat > $TMP/out.osh <<EOF
174+
exec 10>out
175+
echo hello>&10
176+
cat out
177+
EOF
178+
$SH --eval $TMP/out.osh
179+
## STDOUT:
180+
hello
181+
## END
182+
## N-I bash/dash/mksh/zsh STDOUT:
183+
## END
184+
171185
#### Set LC_ALL LC_CTYPE LC_COLLATE LANG - affects glob ?
172186

173187
# note: test/spec-common.sh sets LC_ALL

0 commit comments

Comments
 (0)