-
-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[spec/redirect-glob] New tests for redirects with globs
This is a bash/zsh feature. It's arguably weird, but I did use it, and others may run into it. Part of issue #1521
- Loading branch information
Andy C
committed
Aug 31, 2023
1 parent
8f0e83b
commit c597157
Showing
4 changed files
with
146 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
## compare_shells: bash mksh zsh ash | ||
## oils_failures_allowed: 3 | ||
|
||
#### file redirects with glob args (bash and zsh only) | ||
|
||
touch one-bar | ||
|
||
echo hi > one-* | ||
|
||
cat one-bar | ||
|
||
echo escaped > one-\* | ||
|
||
cat one-\* | ||
|
||
## STDOUT: | ||
hi | ||
escaped | ||
## END | ||
## N-I dash/mksh/ash STDOUT: | ||
escaped | ||
## END | ||
|
||
#### file redirect to $var with glob char | ||
|
||
touch two-bar | ||
|
||
star='*' | ||
|
||
echo hi > two-$star | ||
echo status=$? | ||
|
||
head two-bar two-\* | ||
|
||
## status: 0 | ||
## STDOUT: | ||
status=0 | ||
==> two-bar <== | ||
|
||
==> two-* <== | ||
hi | ||
## END | ||
|
||
## BUG bash status: 1 | ||
## BUG bash STDOUT: | ||
status=0 | ||
==> two-bar <== | ||
hi | ||
## END | ||
|
||
#### file redirect that globs to more than one file (bash and zsh only) | ||
|
||
touch foo-bar | ||
touch foo-spam | ||
|
||
echo hi > foo-* | ||
echo status=$? | ||
|
||
head foo-bar foo-spam | ||
|
||
## STDOUT: | ||
status=1 | ||
==> foo-bar <== | ||
|
||
==> foo-spam <== | ||
## END | ||
|
||
## N-I dash/mksh/ash STDOUT: | ||
status=0 | ||
==> foo-bar <== | ||
|
||
==> foo-spam <== | ||
## END | ||
|
||
## BUG zsh STDOUT: | ||
status=0 | ||
==> foo-bar <== | ||
hi | ||
|
||
==> foo-spam <== | ||
hi | ||
## END | ||
|
||
#### file redirect with extended glob (bash only) | ||
|
||
shopt -s extglob | ||
|
||
touch foo-bar | ||
|
||
echo hi > @(*-bar|other) | ||
echo status=$? | ||
|
||
cat foo-bar | ||
|
||
## status: 0 | ||
## STDOUT: | ||
status=0 | ||
hi | ||
## END | ||
|
||
## N-I zsh status: 1 | ||
## N-I dash/ash status: 2 | ||
|
||
## N-I dash/zsh/ash STDOUT: | ||
## END | ||
|
||
## BUG mksh status: 0 | ||
## BUG mksh STDOUT: | ||
status=0 | ||
## END | ||
|
||
#### other redirects with glob args | ||
|
||
touch 10 | ||
|
||
exec 10>&1 # open stdout as descriptor 10 | ||
|
||
# Does this go to stdout? ONLY bash respects it, not zsh | ||
echo should-not-be-on-stdout >& 1* | ||
|
||
echo stdout | ||
echo stderr >&2 | ||
|
||
## status: 0 | ||
|
||
## STDOUT: | ||
stdout | ||
## END | ||
|
||
## BUG bash STDOUT: | ||
should-not-be-on-stdout | ||
stdout | ||
## END | ||
|
||
## N-I dash/zsh status: 127 | ||
## N-I dash/zsh STDOUT: | ||
## END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters