Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #13792
| Path | csiph.com!weretis.net!feeder6.news.weretis.net!nntp.club.cc.cmu.edu!micro-heart-of-gold.mit.edu!bloom-beacon.mit.edu!bloom-beacon.mit.edu!171.64.64.130.MISMATCH!usenet.stanford.edu!not-for-mail |
|---|---|
| From | Chet Ramey <chet.ramey@case.edu> |
| Newsgroups | gnu.bash.bug |
| Subject | Re: Unset array doesn't work |
| Date | Fri, 2 Mar 2018 14:43:02 -0500 |
| Lines | 70 |
| Approved | bug-bash@gnu.org |
| Message-ID | <mailman.10032.1520019799.27995.bug-bash@gnu.org> (permalink) |
| References | <ba594d01-b9c4-5cd8-9fa0-2f20fd1d2d07@case.edu> <21679c48-4064-5683-2d5f-91bfb76687d0@case.edu> <790ade74-690f-541c-9ab4-6359917442d0@case.edu> <a56e05b1-0b34-1cb2-6073-91c12f27e228@gmail.com> <a642644f-e475-6361-140e-5b47ab4e321c@case.edu> <755d61fa-d2bc-8855-bc30-4388aff40691@gmail.com> <9974.1519637469@jinx.noi.kre.to> <15717.1519764581@jinx.noi.kre.to> <24248.1519844400@jinx.noi.kre.to> |
| Reply-To | chet.ramey@case.edu |
| NNTP-Posting-Host | lists.gnu.org |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8 |
| Content-Transfer-Encoding | 7bit |
| X-Trace | usenet.stanford.edu 1520019800 29168 208.118.235.17 (2 Mar 2018 19:43:20 GMT) |
| X-Complaints-To | action@cs.stanford.edu |
| Cc | chet.ramey@case.edu, bug-bash@gnu.org |
| To | Robert Elz <kre@munnari.OZ.AU> |
| Envelope-to | bug-bash@gnu.org |
| User-Agent | Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 |
| In-Reply-To | <24248.1519844400@jinx.noi.kre.to> |
| Content-Language | en-US |
| X-Junkmail-Status | score=8/60, host=mpv1-2015.case.edu |
| X-Junkmail-PrAS-Raw | score=8/60, refid=2.7.2:2018.3.2.191815:17:8.317, ip=, rules=__HAS_FROM, FROM_EDU_TLD, __BOUNCE_CHALLENGE_SUBJ, __BOUNCE_NDR_SUBJ_EXEMPT, __SUBJ_ALPHA_END, __HAS_REPLYTO, __TO_MALFORMED_2, __TO_NAME, __TO_NAME_DIFF_FROM_ACC, __HAS_CC_HDR, __MULTIPLE_RCPTS_CC_X2, __REFERENCES, __HAS_MSGID, __SANE_MSGID, DATE_TZ_NA, __USER_AGENT, __MOZILLA_USER_AGENT, __MIME_VERSION, __IN_REP_TO, __CT, __CT_TEXT_PLAIN, __CTE, __REPLYTO_SAMEAS_FROM_ADDY, __REPLYTO_SAMEAS_FROM_ACC, __REPLYTO_SAMEAS_FROM_DOMAIN, __ANY_URI, __URI_WITH_PATH, __URI_NO_WWW, __STOCK_PHRASE_24, __CP_URI_IN_BODY, __FRAUD_MONEY_CURRENCY_DOLLAR, __SUBJ_ALPHA_NEGATE, __URI_IN_BODY, __URI_NOT_IMG, __FORWARDED_MSG, __NO_HTML_TAG_RAW, BODYTEXTP_SIZE_3000_LESS, BODY_SIZE_2000_2999, __MIME_TEXT_P1, __MIME_TEXT_ONLY, __URI_NS, HTML_00_01, HTML_00_10, __FRAUD_MONEY_CURRENCY, BODY_SIZE_5000_LESS, IN_REP_TO, MSG_THREAD, __TO_REAL_NAMES, MULTIPLE_REAL_RCPTS, [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-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:13792 |
Show key headers only | View raw
On 2/28/18 2:00 PM, Robert Elz wrote:
> Date: Wed, 28 Feb 2018 10:27:23 -0500
> From: Chet Ramey <chet.ramey@case.edu>
> Message-ID: <ba594d01-b9c4-5cd8-9fa0-2f20fd1d2d07@case.edu>
>
> | These are two different cases -- same context vs. a previous context. Your
> | example is not the same as the original poster's.
>
> OK, though I am not sure why that should make a difference.
It does.
> | The global var is left unchanged, and satisfies references to $var with v1.
>
> The second clause of that is what is brain dead. There should be a simple
> invariant in all shell contexts, which is
>
> unset X
> Y=$X
>
> assigns the null string to Y (except in the case where X is read only, which
> is not a case of concern here.)
Perhaps. But bash has never done this. Not from day one. That's 30 years.
> Always.
>
> No (other) exceptions.
>
> None.
Never done it that way. Ever. Not once. (We can do this all day. But levity
aside.)
>
> Similarly the expression ${X-unset} should always produce "unset" if X
> has been unset and not subsequently given a value.
>
> Whatever else is believed about how variables should work, that part should
> remain true - if we cannot rely upon unset working to create an unset variable,
> then we're lost.
This is how bash dynamic scoping works. The exception for the declaration/
unset at the current scope was added 16 years ago, and the existing
behavior was already entrenched.
> | You can mark any local instances in previous
> | scopes (or the nearest previous scope that has a local instance of
> | that variable) with a special `unset' attribute that will cause
> | references to it to behave as if it were unset, leaving the global
> | value unchanged.
>
> Yes. That's the correct way I believe.
I can see doing this and allowing it to be toggled by a shell option.
> Lastly, where does the notion of "remove" come from?
As a way to describe the historical bash behavior, it works. An instance
of a variable with a given name at a previous scope is removed, and another
instance of that variable at another scope is revealed.
Chet
--
``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: Unset array doesn't work Chet Ramey <chet.ramey@case.edu> - 2018-03-02 14:43 -0500
csiph-web