A NOTE has been added to this issue. ====================================================================== http://austingroupbugs.net/view.php?id=767 ====================================================================== Reported By: dwheeler Assigned To: ajosey ====================================================================== Project: 1003.1(2008)/Issue 7 Issue ID: 767 Category: Shell and Utilities Type: Enhancement Request Severity: Objection Priority: normal Status: Under Review Name: David A. Wheeler Organization: User Reference: Section: XCU 2.14 (local) Page Number: 2374 Line Number: 75650 Interp Status: --- Final Accepted Text: ====================================================================== Date Submitted: 2013-10-11 02:02 UTC Last Modified: 2017-05-23 13:47 UTC ====================================================================== Summary: Add built-in "local" ====================================================================== Relationships ID Summary ---------------------------------------------------------------------- related to 0000771 Expose alternate shell function usage t... related to 0000465 is the list of special built-ins exhaus... related to 0001025 set description contains counterproduct... ======================================================================
---------------------------------------------------------------------- (0003712) chet_ramey (reporter) - 2017-05-23 13:47 http://austingroupbugs.net/view.php?id=767#c3712 ---------------------------------------------------------------------- Re: http://austingroupbugs.net/view.php?id=767#c3702 > I would call a script broken if it expects that "local x" results > in a empty initialized variable. > > It seems to be the "natural" expected behavior for "local" is > to just create a local variant. > > In any case, calling > > local x > x="" > > gives you a state that is the same on all implementations that > already support "local". > > If you add the current POSIX Bourne Shell: > > bosh -c 'x() { local y; echo ${y:-z}; }; y=1; x' > 1 > > you already have a 50:50 ratio of what shell authors believe is useful. > > If we assume that the "local" implementation in mksh and posh (both > descendants of pdksh) are the the same, we already habe a 3:2 ratio > for the decision to let "local x" just create a local variant of an > existing "x". Well, that's the rub. The question of what a `local variant' means is precisely what we're trying to decide. It seems to be consensus that a local variable is an object that `shadows' an instance of a variable with the same name at a previous scope (leaving the discussion of static or dynamic scope aside). The other questions are under debate. Why should an object that shadows another inherit its value? Issue History Date Modified Username Field Change ====================================================================== 2013-10-11 02:02 dwheeler New Issue 2013-10-11 02:02 dwheeler Status New => Under Review 2013-10-11 02:02 dwheeler Assigned To => ajosey 2013-10-11 02:02 dwheeler Name => David A. Wheeler 2013-10-11 02:02 dwheeler Section => XCU 2.14 (local) 2013-10-11 02:02 dwheeler Page Number => 2374 2013-10-11 02:02 dwheeler Line Number => 75650 2013-10-11 08:31 geoffclare Relationship added related to 0000465 2013-10-15 22:47 dwheeler Note Added: 0001912 2013-10-17 05:52 ranjit Note Added: 0001924 2013-10-20 05:00 shware_systems Note Added: 0001937 2013-11-14 16:08 geoffclare Relationship added related to 0000771 2015-04-23 23:12 emaste Issue Monitored: emaste 2016-07-05 09:35 joerg Note Added: 0003285 2016-12-01 16:51 eblake Relationship added related to 0001025 2017-05-19 21:39 mirabilos Note Added: 0003699 2017-05-19 22:12 stephane Note Added: 0003701 2017-05-22 11:19 joerg Note Added: 0003702 2017-05-22 11:20 joerg Note Edited: 0003702 2017-05-22 11:20 joerg Note Edited: 0003702 2017-05-22 11:21 joerg Note Edited: 0003702 2017-05-22 19:38 stephane Note Added: 0003703 2017-05-22 23:06 shware_systems Note Added: 0003704 2017-05-23 03:41 kre Note Added: 0003705 2017-05-23 10:47 shware_systems Note Added: 0003706 2017-05-23 11:07 shware_systems Note Edited: 0003706 2017-05-23 12:06 stephane Note Added: 0003707 2017-05-23 13:08 joerg Note Added: 0003708 2017-05-23 13:18 joerg Note Added: 0003709 2017-05-23 13:19 joerg Note Edited: 0003709 2017-05-23 13:41 chet_ramey Note Added: 0003710 2017-05-23 13:47 joerg Note Added: 0003711 2017-05-23 13:47 chet_ramey Note Added: 0003712 ======================================================================