Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: A bug or improperly formatted script
- X-seq: zsh-users 22500
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: linuxtechguy@xxxxxxxxx, zsh-users@xxxxxxx
- Subject: Re: A bug or improperly formatted script
- Date: Sat, 25 Feb 2017 15:41:40 -0800
- Authentication-results: amavisd4.gkg.net (amavisd-new); dkim=pass (2048-bit key) header.d=brasslantern-com.20150623.gappssmtp.com
- 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=QLbRqkyFyxD3m/hn6h7DUqnX8c0afbQ9dC8vOEw1Gl4=; b=py2RWsm+IGMs02o4NQOj3eKdTp+lKbCVzQb2WfPNq3B8YqfLs5eKnhbR1xvnygHILg ZjgWPyAxblpitYLoc2GS723mYVWSXKvbct0xypJMvOxk/ACpa4EyDrNm5zic64DyzlR+ mCnjZgiUM4R7EL1HLaome8RIpNj994iXTTBIZTLpkYeHMGPmvnNwZfUHMYybcWcKJfDF gYoU49JDNbzDbW3c/fQnCOUCV/EGKaFHmvCa1boG25rcVU5o2enIP7bY4XW+EGC6K+S1 T002ng5TYd4KXbU0DKh4yQjNAoeT3dGeyT+AVFLN75HtMM9Hp4C7l0INl5xMhl8XqVMF k9Rw==
- In-reply-to: <CA+rB6G+5s7QPuT-iRwZHOC3Mg7aSbk+4M7V6wgzTBGjTW_+4yw@mail.gmail.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <CA+rB6GJoCDbdEVYR-zYEh6P0Oau7VAxQeW6UcnksdeB3hvL=HQ@mail.gmail.com> <170225141211.ZM20788@torch.brasslantern.com> <CA+rB6G+5s7QPuT-iRwZHOC3Mg7aSbk+4M7V6wgzTBGjTW_+4yw@mail.gmail.com>
On Feb 25, 4:53pm, Jim wrote:
}
} So in my original email the alternate example
}
} print $((${(z)${(fO)"$(dirs -v)"}[1][1]} + 1))
}
} was this forcing it to an array or was it a fluke?
It was a fluke. ${${$(print $'0\t~')[1]}[1]} == '0' whereas
${${$(print $'0\t~')[-1]}[1]} == '~' and $(( ~ + 1 )) == -2 (the
tilde being interpreted as bitwise negation).
Double-subscripting $var[1][1] yields the same byte whether $var is
a scalar or an array, whereas $var[-1][1] does not unless the scalar
is only a single character to begin with.
You'd never have seen -2 if $HOME were not the only entry in the
stack. With $(dirs -lv) or with most other directories, the last char
of the directory name would have been intepreted as a variable name
and potentially produced even stranger results (though most like it
would be an unset variable and thus be treated as zero, hiding the
effect entirely). A directory name ending in digits would have made
things even stranger.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author