groff
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: utmac -muh error on Ubuntu


From: Tadziu Hoffmann
Subject: Re: utmac -muh error on Ubuntu
Date: Mon, 5 Jul 2021 16:07:12 +0200
User-agent: Mutt/1.11.4 (2019-03-13)

> > echo ".ds head-str ${str: -1}"

> The compatible syntax is ${str:-1}.

I wonder if that is meant, though.

Bash also has

  ${parameter:offset}
  ${parameter:offset:length}
    Substring Expansion.  Expands to up to length characters of
    the value of parameter starting at the character specified
    by offset.

with the caveat that

  Note that a negative offset must be separated from the
  colon by at least one space to avoid being confused with
  the :- expansion.

This latter is something that all Bourne-compatible shells
understand, here in a summary by POSIX:

                     | parameter set        | parameter set   | parameter unset
                     | and not null         | but null        |
  -------------------+----------------------+-----------------+----------------
  ${parameter:-word} | substitute parameter | substitute word | substitute word
  ${parameter-word}  | substitute parameter | substitute null | substitute word
  ${parameter:=word} | substitute parameter | assign word     | assign word
  ${parameter=word}  | substitute parameter | substitute null | assign word
  ${parameter:?word} | substitute parameter | error, exit     | error, exit
  ${parameter?word}  | substitute parameter | substitute null | error, exit
  ${parameter:+word} | substitute word      | substitute null | substitute null
  ${parameter+word}  | substitute word      | substitute word | substitute null

but the purpose of this differs from that of the bashism above.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]