[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Bug in return code from "bash -c '! command'"
From: |
dworley |
Subject: |
Bug in return code from "bash -c '! command'" |
Date: |
Fri, 11 Mar 2005 14:27:11 -0500 |
Environment: Bash 3.00.14(1) running on i386 under Fedora Core 3 Linux.
In Bash 3.00, it seems that the return code from bash is not
duplicated from a command specified by -c if the command starts with
"!".
To reproduce this, write a script:
#! /bin/bash
set -x
bash --version
# Create a file baz containing one line containing @.
cat >baz <<EOF
@
EOF
grep @ baz ; echo $?
! grep @ baz ; echo $?
bash -c "grep @ baz" ; echo $?
bash -c "! grep @ baz" ; echo $?
exit
The output it generates is:
+ bash --version
GNU bash, version 3.00.14(1)-release (i386-redhat-linux-gnu)
Copyright (C) 2004 Free Software Foundation, Inc.
+ cat
+ grep @ baz
@
+ echo 0
0
+ grep @ baz
@
+ echo 1
1
+ bash -c 'grep @ baz'
@
+ echo 0
0
+ bash -c '! grep @ baz'
@
+ echo 0
0
+ exit
In the final test, 'bash -c "! grep @ baz"', the command '! grep @
baz' returns 1, but bash returns 0.
Dale
- Bug in return code from "bash -c '! command'",
dworley <=