forked from savoirfairelinux/cqfd
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This adds the shell command to run a $CQFD_SHELL (or /bin/sh) command from within the container. It is a convenient frontend to "cqfd run bash", which also respects the arguments: $ cqfd shell -c 'printf "0=$0,*=$*,#=$#\n"' zero one two three 0=zero,*=one two three,#=3 While the run command does not: $ cqfd run /bin/bash -c 'printf "0=$0,*=$*,#=$#\n"' zero one two three printf: usage: printf [-v var] format [arguments] $ cqfd run /bin/sh -c 'printf "0=$0,*=$*,#=$#\n"' zero one two three 0=bash,*=,#=0\n: 1: printf: usage: printf format [arg ...] Note: The command shell does not run the command= set in the file .cqfdrc.
- Loading branch information
Showing
5 changed files
with
97 additions
and
3 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
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,18 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# validate the behavior of run command that do not preserve arguments | ||
|
||
set -o pipefail | ||
|
||
. "$(dirname "$0")"/jtest.inc "$1" | ||
cqfd="$TDIR/.cqfd/cqfd" | ||
|
||
cd $TDIR/ | ||
|
||
jtest_prepare "cqfd run do not preserve the arguments" | ||
if ( ! $cqfd run /bin/sh -c 'printf "0=$0,*=$*,#=$#"' zero one two three ) \ | ||
| grep "0=sh,\*=,#=0"; then | ||
jtest_result pass | ||
else | ||
jtest_result fail | ||
fi |
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,42 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# validate the behavior of shell command | ||
|
||
set -o pipefail | ||
|
||
unset CQFD_SHELL | ||
|
||
. "$(dirname "$0")"/jtest.inc "$1" | ||
cqfd="$TDIR/.cqfd/cqfd" | ||
|
||
cd $TDIR/ | ||
|
||
jtest_prepare "cqfd shell should succeed with no stdin" | ||
if $cqfd shell </dev/null; then | ||
jtest_result pass | ||
else | ||
jtest_result fail | ||
fi | ||
|
||
jtest_prepare "cqfd shell should read commands from stdin" | ||
if ( ! $cqfd shell <<<"tty" ) | grep "not a tty"; then | ||
jtest_result pass | ||
else | ||
jtest_result fail | ||
fi | ||
|
||
jtest_prepare "cqfd shell should preserve the arguments" | ||
if $cqfd shell -c 'printf "0=$0,*=$*,#=$#"' zero one two three \ | ||
| grep "0=zero,\*=one two three,#=3$"; then | ||
jtest_result pass | ||
else | ||
jtest_result fail | ||
fi | ||
|
||
jtest_prepare "cqfd shell should fail with 127 if \$CQFD_SHELL is not found" | ||
if CQFD_SHELL=/bin/non-existant-shell $cqfd shell <<<"tty"; | ||
test "$?" -eq 127; then | ||
jtest_result pass | ||
else | ||
jtest_result fail | ||
fi |