Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: padding.
- X-seq: zsh-users 22454
- From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- To: Ray Andrews <rayandrews@xxxxxxxxxxx>
- Subject: Re: padding.
- Date: Sun, 12 Feb 2017 06:14:55 +0000
- Cc: zsh-users@xxxxxxx
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= daniel.shahaf.name; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc:x-sasl-enc; s= mesmtp; bh=gQ/xltkg1Zfhi7GotHfJd8pddxk=; b=XmXc+sLZXis5uCHwazSjb oaHlhtslppZ7iAOqIKgWIgAEEvTiwVkA2uWEDKee5hEGE4W3HQ9hY7ahAjmCfNVN pIa4HpPVF/mUb+MmJRUFSzmKy16AzQgcyCRnQcnVEybphm44kt9PHaDGCasurub1 aOwbRIeD9VVDyQK+Oxte7w=
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc:x-sasl-enc; s= smtpout; bh=gQ/xltkg1Zfhi7GotHfJd8pddxk=; b=V8G7TVQNJRChFaqEGFeF NIUIZdF0CBSMKa94rJ/G6v+JzWs4/Z4iC85ji5OgiHUprmwpLofthom0hm5YtHLh BF1K6WVKdblC++rQ+LoIy95V17qlNPrlPRbL0MWtMOuKQrRUobrai63erYC81jDG 5Hczi19SR4dQRzrdTFvGGvI=
- In-reply-to: <ee3c8ad2-41e3-f3e4-9347-d6e395b85d8e__47549.2452657365$1486864527$gmane$org@eastlink.ca>
- 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: <0befdb38-eaa5-6388-a3fe-58b1a73834b7@eastlink.ca> <170211110437.ZM467@torch.brasslantern.com> <ee3c8ad2-41e3-f3e4-9347-d6e395b85d8e__47549.2452657365$1486864527$gmane$org@eastlink.ca>
[@all: the second hunk is of independent interest]
Ray Andrews wrote on Sat, Feb 11, 2017 at 17:54:09 -0800:
> On 11/02/17 11:04 AM, Bart Schaefer wrote:
> >integer -Z 6 vvar=-1
>
> Perfect! Amazing what's hiding under the hood. I always prefer to do as
> much as possible with built in functionality.
> >I don't think you can, except by specifying a field width of 6. Even
> >printf is going to treat the "-" as part of the field width.
>
> Yeah, it would be more complicated and more involved to get a neat printout.
> The engineer in me does want the field width to be independent of the sign,
> but it's a trivial matter.
printf is not a reserved word (it isn't part of the syntax), however,
it _is_ builtin to the shell:
% which printf
printf: shell built-in command
If printf weren't a builtin, it wouldn't have been able to grow the
«-v variablename» flag.
> BTW, is this kosher:
>
>
> $ if [ "$1" = "start" ]; then
> if [ "$1" = 'null' ] && return
> fi
>
> (no message)
Reduced example:
% if false; then if true; fi
% setopt noshortloops
% if false; then if true; fi
zsh: parse error near `fi'
I'm guessing the second 'if' is parsed using the SHORT_LOOPS syntax,
with an empty sublist. I'm not sure whether that's a bug: is the
sublist in the SHORT_LOOPS syntax allowed to be null?
What about the following variant:
if true; then if exit 42; fi
Should it exit() or report a syntax error about a missing 'fi'?
> and:
>
> $ if [ "$1" = "start" ]; then
> # if [ "$1" = 'null' ] && return
> fi
>
> (no message)
That's expected.
In a script or with INTERACTIVE_COMMENTS, the outer if's body is empty.
Interactively and with INTERACTIVE_COMMENTS unset, the outer if's body
invokes the '#' command with its ${argv[1]} set to the two-character
string "if". That would report "command not found" if the outer
condition were true, but is nonetheless not a syntax error; it's
exactly equivalent to:
if false; then
this-is-not-a-command-name arg1 arg2
fi
which is not a syntax error, either. It's a runtime error.
> but:
>
> $ # if [ "$1" = "start" ]; then
> if [ "$1" = 'null' ] && return
> # fi
>
> ./test2:7: parse error near `\n'
Again, this is parsed differently depending on whether
comments are being parsed.
With comments enabled, this is a syntax error because the if on line 2
is unterminated.
With comments disabled, this is a syntax error because the 'then' on the
first line doesn't follow an if.
Cheers,
Daniel
Messages sorted by:
Reverse Date,
Date,
Thread,
Author