Skip to content

Commit

Permalink
ovs-macros.at: Better hide 'exec -a' checking.
Browse files Browse the repository at this point in the history
There is some issue with parsing of redirection options
on some shells. For example:

  $ (exec -a name true) 2>&1 >/dev/null || echo "failed"
  sh: 10: exec: -a: not found
  failed

  $ (exec -a name true) >/dev/null 2>&1 || echo "failed"
  failed

So, the order of redirections matters for some reason.
Let's replace our current version with simple redirection of stderr.
This version seems to work in most of shells except [t]csh. But it's
really tricky to write portable redirections that works with csh and
this shell will not be used by the testsuite on most of the systems.

With the new version:

  # cat test.sh
  ((exec -a myname true 2>/dev/null) && echo "OK") || echo "fail"

  # sh ./test.sh
  fail
  # bash ./test.sh
  OK
  # tcsh ./test.sh
  -a: Command not found.
  fail

Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Signed-off-by: 0-day Robot <robot@bytheb.org>
  • Loading branch information
igsilya authored and ovsrobot committed Jan 25, 2019
1 parent 9e4f118 commit 6b204f4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tests/ovs-macros.at
Expand Up @@ -173,7 +173,7 @@ uuidfilt () {
# prints a message if a bunch of identical processes are running.
#
# Not all shells support "exec -a NAME", so test for it.
if (exec -a myname true 2>&1 >/dev/null); then
if (exec -a myname true 2>/dev/null); then
run_as () {
(exec -a "$@")
}
Expand Down

0 comments on commit 6b204f4

Please sign in to comment.