Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #14440
| Path | csiph.com!goblin2!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail |
|---|---|
| From | Chet Ramey <chet.ramey@case.edu> |
| Newsgroups | gnu.bash.bug |
| Subject | Re: failglob handling |
| Date | Fri, 3 Aug 2018 11:33:14 -0400 |
| Lines | 109 |
| Approved | bug-bash@gnu.org |
| Message-ID | <mailman.4655.1533310422.1292.bug-bash@gnu.org> (permalink) |
| References | <cb5f1669-3a0b-f9ce-6994-e4b0c7d31bd0@gentoo.org> |
| Reply-To | chet.ramey@case.edu |
| NNTP-Posting-Host | lists.gnu.org |
| Mime-Version | 1.0 |
| Content-Type | multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="MagsMqyTmbHXO6JhXhPpCn8oypux1sYuF" |
| X-Trace | usenet.stanford.edu 1533310423 22580 208.118.235.17 (3 Aug 2018 15:33:43 GMT) |
| X-Complaints-To | action@cs.stanford.edu |
| Cc | chet.ramey@case.edu |
| To | Thomas Deutschmann <whissi@gentoo.org>, bug-bash@gnu.org |
| Envelope-to | bug-bash@gnu.org |
| Openpgp | preference=signencrypt |
| Autocrypt | addr=chet.ramey@case.edu; prefer-encrypt=mutual; keydata= xsDiBEEOsGwRBACFa0A1oa71HSZLWxAx0svXzhOZNQZOzqHmSuGOG92jIpQpr8DpvgRh40Yp AwdcXb8QG1J5yGAKeevNE1zCFaA725vGSdHUyypHouV0xoWwukYO6qlyyX+2BZU+okBUqoWQ koWxiYaCSfzB2Ln7pmdys1fJhcgBKf3VjWCjd2XJTwCgoFJOwyBFJdugjfwjSoRSwDOIMf0D /iQKqlWhIO1LGpMrGX0il0/x4zj0NAcSwAk7LaPZbN4UPjn5pqGEHBlf1+xDDQCkAoZ/VqES GZragl4VqJfxBr29Ag0UDvNbUbXoxQsARdero1M8GiAIRc50hj7HXFoERwenbNDJL86GPLAQ OTGOCa4W2o29nFfFjQrsrrYHzVtyA/9oyKvTeEMJ7NA3VJdWcmn7gOu0FxEmSNhSoV1T4vP2 1Wf7f5niCCRKQLNyUy0wEApQi4tSysdz+AbgAc0b/bHYVzIf2uO2lIEZQNNt+3g2bmXgloWm W5fsm/di50Gm1l1Na63d3RZ00SeFQos6WEwLUHEB0yp6KXluXLLIZitEJM0gQ2hldCBSYW1l eSA8Y2hldC5yYW1leUBjYXNlLmVkdT7CYQQTEQIAIQIbAwYLCQgHAwIDFQIDAxYCAQIeAQIX gAUCRX3FIgIZAQAKCRC7WGnwZOp0q069AKCNDRn+zzN/AHbaynls/Lvq1kH/RQCgkLvF8bDs maUHSxSIPqzlGuKWDxbOwE0EQQ6wbxAEAJCukwDigRDPhAuI+lf+6P64lWanIFOXIndqhvU1 3cDbQ/Wt5LwPzm2QTvd7F+fcHOgZ8KOFScbDpjJaRqwIybMTcIN0B2pBLX/C10W1aY+cUrXZ gXUGVISEMmpaP9v02auToo7XXVEHC+XLO9IU7/xaU98FL69l6/K4xeNSBRM/AAMHA/wNAmRB pcyK0+VggZ5esQaIP/LyolAm2qwcmrd3dZi+g24s7yjV0EUwvRP7xHRDQFgkAo6++QbuecU/ J90lxrVnQwucZmfz9zgWDkT/MpfB/CNRSKLFjhYq2yHmHWT6vEjw9Ry/hF6Pc0oh1a62USdf aKAiim0nVxxQmPmiRvtCmcJJBBgRAgAJBQJBDrBvAhsMAAoJELtYafBk6nSr43AAn2ZZFQg8 Gs/zUzvXMt7evaFqVTzcAJ0cHtKpP1i/4H4R9+OsYeQdxxWxTQ== |
| User-Agent | Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 |
| In-Reply-To | <cb5f1669-3a0b-f9ce-6994-e4b0c7d31bd0@gentoo.org> |
| X-Junkmail-Status | score=8/90, host=mpv1-2015.case.edu |
| X-Junkmail-PrAS-Raw | score=8/90, refid=2.7.2:2018.8.3.150616:17:8.317, ip=, rules=__HAS_REPLYTO, __HAS_CC_HDR, __SUBJ_REPLY, LEO_OBFU_SUBJ_RE, __BOUNCE_CHALLENGE_SUBJ, __BOUNCE_NDR_SUBJ_EXEMPT, __SUBJ_ALPHA_END, __TO_MALFORMED_2, __TO_NAME, __TO_NAME_DIFF_FROM_ACC, __REFERENCES, __HAS_FROM, FROM_EDU_TLD, __HAS_MSGID, __SANE_MSGID, DATE_TZ_NA, __USER_AGENT, __MOZILLA_USER_AGENT, __MIME_VERSION, __IN_REP_TO, __CT, __CTYPE_HAS_BOUNDARY, __CTYPE_MULTIPART, __REPLYTO_SAMEAS_FROM_ADDY, __REPLYTO_SAMEAS_FROM_ACC, __FROM_DOMAIN_IN_ANY_CC1, __FROM_DOMAIN_IN_ANY_CC2, __REPLYTO_SAMEAS_FROM_DOMAIN, __MIME_TEXT_P2, __HAS_ATTACHMENT1, __ANY_URI, __URI_WITH_PATH, __URI_NO_WWW, __CP_URI_IN_BODY, __FRAUD_MONEY_CURRENCY_DOLLAR, __SUBJ_ALPHA_NEGATE, __URI_IN_BODY, __URI_NOT_IMG, __FORWARDED_MSG, __NO_HTML_TAG_RAW, __ATTACHMENT_SIZE_0_10K, __HAS_ATTACHMENT2, BODYTEXTP_SIZE_3000_LESS, BODY_SIZE_3000_3999, __MIME_TEXT_P1, __URI_NS, HTML_00_01, HTML_00_10, [TRUNCATED], so=2010-03-03 19:42:08, dmn=2016-08-03-0138 |
| X-detected-operating-system | by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] [fuzzy] |
| X-Received-From | 129.22.103.226 |
| X-Content-Filtered-By | Mailman/MimeDel 2.1.21 |
| X-BeenThere | bug-bash@gnu.org |
| X-Mailman-Version | 2.1.21 |
| 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 | <http://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> |
| Xref | csiph.com gnu.bash.bug:14440 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
On 8/3/18 9:29 AM, Thomas Deutschmann wrote: > Hi, > > please see the following script: > >> #!/bin/bash >> shopt -s failglob >> if [[ $? -ne 0 ]]; then >> echo 'shopt failed' >> exit 1 >> fi >> >> # Let's view current options just to be sure >> shopt -p >> >> # The following glob should fail because /foo/bar does not exist ... >> # Due to 'failglob' option, bash should stop here >> echo /foo/bar/* >> >> # This code should never run if previous glob failed >> echo Still alive > > Is the assumption true that "Still alive" should *never* be printed > when "/foo/bar" does not exist? It might be an assumption, but it's not correct. The documentation says that failglob affects the command: "If the failglob shell option is set, and no matches are found, an error message is printed and the command is not executed." > When you add "set -e" to the beginning, execution will stop immediately > after the failing glob, i.e. no "Still alive" will be printed. Because set -e will cause the shell to exit when a command fails. > > However, see the following interesting difference between semicolons and > newlines: > >> $ echo "shopt -s failglob; echo /foo/bar/*; echo alive; " | bash >> bash: line 1: no match: /foo/bar/* >> $ echo "shopt -s failglob; echo /foo/bar/*; echo alive; " | sed 's:; :\n:g' | bash >> bash: line 2: no match: /foo/bar/* >> alive >> $ echo "set -e; shopt -s failglob; echo /foo/bar/*; echo alive; " | sed 's:; :\n:g' | bash >> bash: line 3: no match: /foo/bar/* The failglob option affects the command. The `difference' between a line and multiple lines is that bash always reads at least one complete line of input before parsing and executing any of the commands on that line. As a result: shopt -s failglob; echo /foo/bar/*; echo alive is a single compound command, and shopt -s failglob echo /foo/bar/* echo alive is three simple commands. So failglob causes the current command to fail, which means the compound command (first case) or the simple command (second case). `failglob' has behaved this way since it was introduced in bash-3.0. -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRU chet@case.edu http://tiswww.cwru.edu/~chet/
Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread
Re: failglob handling Chet Ramey <chet.ramey@case.edu> - 2018-08-03 11:33 -0400
csiph-web