Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [PATCH] Enable further expansion of parameter name by ${!...}
- X-seq: zsh-workers 39919
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: "zsh-workers@xxxxxxx" <zsh-workers@xxxxxxx>
- Subject: Re: [PATCH] Enable further expansion of parameter name by ${!...}
- Date: Fri, 11 Nov 2016 08:58:39 -0800
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=from:message-id:date:in-reply-to:comments:references:to:subject :mime-version; bh=J0keE7I0eRS6Yz10yTSMCUXPLJ1omSE4XT++hmSE+Ws=; b=BR2j+QXlDfK+Htwk7bKZU9S0YQ6i2fHX4E6qd1RwMVvlmzM+llZOnLS5Tx66o2k7uz ytgRIT+w21JiNyuhYDNf3I4DU0OySQtO0HgDLVMMsYzx6kBS6RFgegVpxRH4DTjiY4nQ N2SZGu2yC/zxrmXUJMMn1/paJNBT4DzQCWBtYuFFnatkCFHdWSSeU/Z5vbYeinkDj1Xv JDSlfv9wJT7AgwYgkByI/g7NxmPEKY/cJ2B2xavmT0y+3avQrYztQkvnuicToaYLOL9m EOjxdvxtQQNrextGvDqWv1EIdsU7flnQyDCpAP3nlYBW+zTLffgQg/zETIvjgCkd6y+K /Yig==
- In-reply-to: <150126214831.ZM551@torch.brasslantern.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <1422177338-85472-1-git-send-email-tomoki.sekiyama@gmail.com> <150125122410.ZM31619@torch.brasslantern.com> <10496951422218331@web21g.yandex.ru> <150125133931.ZM32124@torch.brasslantern.com> <CAM1upfMhyMPCn5urXPUjSTE2K2T3KyaZG6cg2v8vDhWwmHruvw@mail.gmail.com> <150126214831.ZM551@torch.brasslantern.com>
Noticed patches related to this in my git stash. The thread dies out
without an answer to the question of which default behavior to choose.
I'll quote the entire year-old last substantive message for reference.
On Jan 26, 2015, 9:48pm, Bart Schaefer wrote:
} Subject: Re: [PATCH] Enable further expansion of parameter name by ${!...}
}
} On Jan 26, 3:00pm, Tomoki Sekiyama wrote:
} }
} } # ksh bash zsh(default) zsh(KSH)
} } echo $aaa # bbb bbb bbb bbb
} } echo ${!aaa} # aaa ccc bad substitution bbb
}
} OK, but the point is that ideally in that last row the zsh(KSH) case
} would be "aaa". I guess this is no worse than the difference of
} ${array[1]} with or without ksharrays set. (If "nameref aaa=bbb",
} then the first column of the last row would be "bbb".)
}
} } # ksh bash zsh(default) zsh(KSH)
} } echo ${!foo[bar]} # foo[bar] piyo bad substitution bar
}
} I find this one interesting, because the ksh doc says it "expands to the
} name of the subscript" which would seem to me to fit the zsh(KSH) column
} more than the ksh column.
}
} Ksh also has the special case ${!foo[bar..baz]} which treats the array
} keys as an alphabetical list and generates a sub-list of them from "bar"
} through "baz" (uninteresting in this example).
}
} } According to this, introducing bash-like behaviors instead of "bad
} } substitution" error will not hurt zsh even in ksh emulation mode.
}
} My question is, why choose the bash behavior for the zsh default and
} not the ksh behavior? If we make the bash behavior the default, then
} also adding namerefs as a default leaves us deviating from ksh on the
} meaning of ${!aaa} for identifiers that are not namerefs.
The patch I have (workers/34390) implements the bash behavior as the
default, without changing zsh's incorrect ksh emulation.
Obviously we're nowhere close to adding namerefs, so maybe we should just
punt on this until that happens.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author