Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 30 May 2010 21:35:07 +0300
From:      Giorgos Keramidas <keramida@ceid.upatras.gr>
To:        Aiza <aiza21@comclark.com>
Cc:        "questions@freebsd.org" <questions@freebsd.org>
Subject:   Re: sh script writing help
Message-ID:  <87wrul2q78.fsf@kobe.laptop>
In-Reply-To: <4C01F419.10100@comclark.com> (Aiza's message of "Sun, 30 May 2010 13:14:01 %2B0800")
References:  <4C01F419.10100@comclark.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, 30 May 2010 13:14:01 +0800, Aiza <aiza21@comclark.com> wrote:
> In a .sh type script I have && exerr " very long message gt 250 char"
> all on the same line. This is a real pain to edit.
>
> Is there some code a can use to continue this on the next line so I
> can see it on the screen and still have the command function? I tried
> \ with no luck.

If the message does not have to be a *single* command-line argument of
the exerr function, you can split the message in multiple arguments
and use '\' for continuation lines, e.g.:

    echo "This is a very long message" \
        "that does not fit in a single" \
        "line of text."

This might not work if you _have_ to pass the string as a single
argument, but even in that case you can use shell substitution to wrap
the exerr() function, e.g.:

    exwrap()
    {
        return exerr "$*"
    }

    exwrap "This is a very long message" \
        "that does not fit in a single" \
        "line of text."




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?87wrul2q78.fsf>