Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
bug in parameter expansion
- X-seq: zsh-workers 30782
- From: Scott Moser <smoser@xxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: bug in parameter expansion
- Date: Wed, 7 Nov 2012 14:13:36 -0500 (EST)
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:date:from:x-x-sender:to:subject:message-id:user-agent :mime-version:content-type; bh=qDQNCnBj4QKgHc+ejVQcoV32Pa2x353t7sGoWHThGRI=; b=cxsYwOjSQz8Vf9X2EhgtRvBvzbOHh1I0VjmQoVntdjx2Y6neYss+bNdloDOXbyYweK jShmrxLEu1dAcJkF9YZUtx8W8jNLHRSqN2p8x98sO3QPlzqmW7ooebl9xCgj3Zm/ypKO Menr7RS7UHBArtT2XCkcPbnn/6vvWLiRTh1NnZ4IS0rjKZiSDLj2PgpzYqkS7x/kP2I5 GHo6tTHNfWi4YKEhmTPx9czPpiuUAwAQ/ZWEcrCABQbf2d0L6XwoiTNtffK3km75s4O4 upIni4R+JiwUq4cYAsMztnvh/H0xIhNtUtuhU4aUtoP5MqgmwZF6fXrwXCiehW7+f/m8 x+9Q==
- 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
- Sender: Scott Moser <ssmoser2@xxxxxxxxx>
This issue was initially reported against shell code delivered in
cloud-init at [1], but it seems to me to be a bug in zsh's posix shell
behavior.
$ for shell in /bin/dash /bin/bash /bin/ksh /bin/zsh; do \
echo "=== $shell ==="; $shell -c 'echo "${1%%=*}"' \
-- A=B; done
=== /bin/dash ===
A
=== /bin/bash ===
A
=== /bin/ksh ===
A
=== /bin/zsh ===
zsh:1: * not found
It also has the issue when matching prefix (#):
$ zsh -c 'echo ${1#=?}' -- =AB
zsh:1: ? not found
$ bash -c 'echo ${1#=?}' -- =AB
B
It is seemingly easily worked around by escaping the '=' like:
$ zsh -c 'echo "${1%%\=*}"' -- A=B
A
or:
zsh -c 'equal="="; echo "${1%%${equal}*}"' -- A=B
A
Scott
--
[1] https://bugs.launchpad.net/ubuntu/+source/cloud-init/+bug/1073077
Messages sorted by:
Reverse Date,
Date,
Thread,
Author