[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] ${var:?message} customization
From: |
Matias A. Fonzo |
Subject: |
Re: [Help-bash] ${var:?message} customization |
Date: |
Thu, 14 May 2015 18:30:39 -0300 |
Hello Stephane,
El Thu, 14 May 2015 10:09:34 +0100
Stephane Chazelas <address@hidden> escribió:
> 2015-05-13 20:54:09 -0300, Matias A. Fonzo:
> > Hi there,
> >
> > Normally, "${var:?'message'}" display error if null or unset if
> > 'message' is omitted. But if it is not, a particular message can be
> > included, in any case, shows (e.g):
> >
> > myscript: line 2: var: parameter null or not set
> >
> > My question is, there is a way to print only the message? (removing
> > myscript: line number: var:)
> [...]
>
> I don't think so, but if stderr is going to a terminal, you
> could tell the terminal to erase it:
>
> ${var:?$'\r\e[Kblah blah}
Very interesting. This is what I am looking for, BTW there is a missing
' in the right-side.
> In most terminals
> \r brings the cursor to the first column
> \e[K deletes to the end of the line.
>
> If your message is bigger than the line number prolog, you can
> ommit the \e[K part.
>
> In anycase, you can always to it by and:
>
> # for ${var:?blah}
> if [ -z "$var" ]; then
> echo >&2 blah
> exit 1
> fi
> # for ${var?blah}
> if [ -z "${var++}" ]; then
> echo >&2 blah
> exit 1
> fi
>
It is good to know it. Thanks!
- [Help-bash] ${var:?message} customization, Matias A. Fonzo, 2015/05/13
- Re: [Help-bash] ${var:?message} customization, Stephane Chazelas, 2015/05/14
- Re: [Help-bash] ${var:?message} customization,
Matias A. Fonzo <=
- Re: [Help-bash] ${var:?message} customization, Greg Wooledge, 2015/05/14
- Re: [Help-bash] ${var:?message} customization, Dan Douglas, 2015/05/14
- Re: [Help-bash] ${var:?message} customization, Stephane Chazelas, 2015/05/15
- Re: [Help-bash] ${var:?message} customization, Dan Douglas, 2015/05/15
Re: [Help-bash] ${var:?message} customization, Matias A. Fonzo, 2015/05/14