Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: padding.



On Feb 10,  7:15pm, Ray Andrews wrote:
} Subject: padding.
}
} $ integer -x vvar=-1
} $ echo ${(l:5::0:)vvar}
} 
} How do I get "-00005"?

In addition to the suggestion of printf,

integer -Z 6 vvar=-1

    -Z [ N ]
          Specially handled if set along with the -L flag.  Otherwise,
          similar to -R, except that leading zeros are used for padding
          instead of blanks if the first non-blank character is a digit.
          Numeric parameters are specially handled: they are always
          eligible for padding with zeroes, and the zeroes are inserted
          at an appropriate place in the output.

} But also with the negative not counting as part of
} of the padding?

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.



Messages sorted by: Reverse Date, Date, Thread, Author