Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #16331

bash errexit shell option does not work in some cases.

Path csiph.com!xmission!news.snarked.org!news.linkpendium.com!news.linkpendium.com!panix!usenet.stanford.edu!not-for-mail
From Hyunho Cho<mug896@naver.com>
Newsgroups gnu.bash.bug
Subject bash errexit shell option does not work in some cases.
Date Mon, 01 Jun 2020 11:32:05 +0900
Lines 26
Approved bug-bash@gnu.org
Message-ID <mailman.869.1590978736.2541.bug-bash@gnu.org> (permalink)
References <3f403934d6b5d23ca58afc5146416c7@cweb006.nm.nfra.io>
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0
Content-Type text/plain; charset="utf-8"
Content-Transfer-Encoding base64
X-Trace usenet.stanford.edu 1590978736 15623 209.51.188.17 (1 Jun 2020 02:32:16 GMT)
X-Complaints-To action@cs.stanford.edu
To <bug-bash@gnu.org>
Envelope-to bug-bash@gnu.org
X-Naver-CIP 211.192.208.211
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/simple; d=naver.com; s=s20171208; t=1590978726; bh=z8uALYtd4vPQh/90Yed+Ra/w8RRT362KjlhqFNHkf8M=; h=Message-ID:Date:From:To:Subject; b=Wg8zXu2y3xYXogQnq+GJ0XbU/3LKq/PDMVLWZW6GYDUKCHAkOVN4EsB9mm+WgeGzP 4duYGkRCJ3gRk5UmroSKsQg/sOeedxl2/NV41EKlu9WNOwUo1zl+qNMiYOZpkTvGTm XcIIPdzdiDG7PuEyqZ+Wb3IIzJ8Rr91kTauTspq0Djb4BnlTG9Q3D/Va1+3GILGa1k JDHIHl7zY2mgBIaXXW6GG997d6uA+NUTI2SwEA9JCQDTzcK2tTsrEfNreFfXcJ+CNA ZIMrI3MGi8/6fz9s2nwr7TN85/4X3nHFfvm4z/0gjF4T+Hn1O22UDCsm93u3XTSOjf t4adv+mCr+a+A==
X-Session-ID 8ebrKAgZKAUTFAblBqumWBkNaAvr7qbmaxbXFxtmFxgm
Importance normal
X-Originating-IP 211.192.208.211
Received-SPF pass client-ip=125.209.224.202; envelope-from=mug896@naver.com; helo=cvsmtppost003.nm.naver.com
X-detected-operating-system by eggs.gnu.org: First seen = 2020/05/31 22:32:06
X-ACL-Warn Detected OS = Linux 3.1-3.10 [fuzzy]
X-Spam_score_int -15
X-Spam_score -1.6
X-Spam_bar -
X-Spam_report (-1.6 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, FROM_EXCESS_BASE64=0.979, FROM_MISSP_FREEMAIL=0.001, RCVD_IN_DNSWL_LOW=-0.7, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN
X-Spam_action no action
X-BeenThere bug-bash@gnu.org
X-Mailman-Version 2.1.23
Precedence list
List-Id Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org>
List-Unsubscribe <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe>
List-Archive <https://lists.gnu.org/archive/html/bug-bash>
List-Post <mailto:bug-bash@gnu.org>
List-Help <mailto:bug-bash-request@gnu.org?subject=help>
List-Subscribe <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe>
X-Mailman-Original-Message-ID <3f403934d6b5d23ca58afc5146416c7@cweb006.nm.nfra.io>
Xref csiph.com gnu.bash.bug:16331

Show key headers only | View raw


GNU bash, version 5.0.16(1)-release (x86_64-pc-linux-gnu)
 Operating System: Ubuntu 20.04 LTS
 Kernel: Linux 5.4.0-33-generic
 Architecture: x86-64


bash errexit shell option does not work in some cases.
after execution a command, exitcode is set to "1" but shell script does not exited.


#################   WORK CASE   #######################

#!/bin/bash -e                   # errexit option

cat < not_exist.txt             # not exist file

echo end ....

######  result  ######

$ ./test.sh                          # work as expected
./test.sh: line 3: not_exist.txt: No such file or directory


###################   NOT WORK  CASES  #######################

#!/bin/bash -e

{ cat ;} < not_exist.txt   

echo "exitcode : $?"
echo end ....

######  result  ######

$ ./test.sh         
exitcode : 1           # exitcode is set to "1" 
./test.sh: line 3: not_exist.txt: No such file or directory
end ....                  # but test.sh does not exited

--------------------------------------------------------------------------------------

#!/bin/bash -e           

while read -r line; do 
    echo "$line"
done < not_exist.txt  

echo "exitcode : $?"
echo end.....

######  result  ######

$ ./test.sh
./test.sh: line 5: not_exist.txt: No such file or directory
exitcode : 1        # exitcode is set to "1"
end.....                # but does not exited

Back to gnu.bash.bug | Previous | Next | Find similar


Thread

bash errexit shell option does not work in some cases. Hyunho Cho<mug896@naver.com> - 2020-06-01 11:32 +0900

csiph-web