zsh-users
 help / color / mirror / code / Atom feed
* ${var:1:1:=y}
@ 2015-02-03 23:12 Ray Andrews
  2015-02-04  0:18 ` ${var:1:1:=y} Lawrence Velázquez
  0 siblings, 1 reply; 16+ messages in thread
From: Ray Andrews @ 2015-02-03 23:12 UTC (permalink / raw)
  To: Zsh Users

We can of course do this:

     variable=${var:=xy}

I'm wanting the naive expansion of that syntax to do this:

     variable=${var:1:1:=y}

... but it doesn't work. Can something like that be done?
At the moment I'm doing this:

     variable=${var:1:1}
     [ -n "$variable" ] || variable=y

... which is perfectly fine, but the above pseudosyntax would be elegant 
if it could be made workable.


And I found something that puzzles me:


    test ()
    {
       echo $1
       echo ${1:0:1}
       /bin/echo ${1:0:1}
       echo ${1:1:1}
       echo ${1:0:1}${1:1:1}
       echo ${1:1:1}${1:0:1}
    }

    $ test -a

    -a
    [nothing]
    -
    a
    -a
    a-

... If I entered a valid switchofcourse I'd expect that to be eaten
but a solitary dash? Bug?  /bin/echo behaves as I'd expect.



^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2015-02-05  2:25 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-03 23:12 ${var:1:1:=y} Ray Andrews
2015-02-04  0:18 ` ${var:1:1:=y} Lawrence Velázquez
2015-02-04  0:39   ` ${var:1:1:=y} Ray Andrews
2015-02-04  1:30     ` ${var:1:1:=y} Lawrence Velázquez
2015-02-04  3:25       ` ${var:1:1:=y} Bart Schaefer
2015-02-04  3:44         ` ${var:1:1:=y} Eric Cook
2015-02-04 17:10           ` The "-" and "--" options (was Re: ${var:1:1:=y}) Bart Schaefer
2015-02-04 17:42             ` Ray Andrews
2015-02-04 23:47               ` Lawrence Velázquez
2015-02-05  1:31                 ` Ray Andrews
2015-02-05  1:52                   ` Kurtis Rader
2015-02-05  2:03                     ` Ray Andrews
2015-02-05  2:24               ` Bart Schaefer
2015-02-04 19:02             ` Peter Stephenson
2015-02-04 19:53               ` ZyX
2015-02-04  5:16         ` ${var:1:1:=y} Ray Andrews

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).