Skip to content

Commit

Permalink
[spec/builtins2] Add test cases for 'command -p' (#1808)
Browse files Browse the repository at this point in the history
  • Loading branch information
KingMob committed Jan 25, 2024
1 parent 889a57a commit b5633a4
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion spec/builtins2.test.sh
@@ -1,4 +1,4 @@
## oils_failures_allowed: 0
## oils_failures_allowed: 3
## compare_shells: dash bash mksh zsh


Expand Down Expand Up @@ -366,6 +366,35 @@ status=127
status=127
## END

#### command -p (override existing program)
# Tests whether command -p overrides the path
# tr chosen because we need a simple non-builtin
mkdir -p $TMP/bin
echo "echo wrong" > $TMP/bin/tr
chmod +x $TMP/bin/tr
PATH="$TMP/bin:$PATH"
echo aaa | tr "a" "b"
echo aaa | command -p tr "a" "b"
rm $TMP/bin/tr
## STDOUT:
wrong
bbb
## END

#### command -p (hide tool in custom path)
mkdir -p $TMP/bin
echo "echo hello" > $TMP/bin/hello
chmod +x $TMP/bin/hello
export PATH=$TMP/bin
command -p hello
## status: 127

#### command -p (find hidden tool in default path)
export PATH=''
command -p ls
## status: 0


#### $(command type ls)
type() { echo FUNCTION; }
type
Expand Down

0 comments on commit b5633a4

Please sign in to comment.