tobold.org

correct • elegant • free

△ comp.unix.shell △

◅ Processing non-empty stdout/stderr

nohup in ksh ▻

nested expr commands

In article <slrn7vq8qk.ue.ken@pulsar.halcyon.com>, Ken Pizzini
wrote:
>I agree that rc is a nicely designed shell, but it doesn't
>really have a noticable advantage over other "modern" shells
>WRT the specific issue of nesting command-substitutions.

One minor difference is that rc parses the entire line in one go, so
shell syntax errors within the nested command substitution are caught
immediately.

To resuscitate an example from an earlier thread...

    bash$ echo You have $(expr $(frm |wc -l) - 1) messages
    You have 0 messages

    rc; echo You have `{expr `{frm |wc -l} - 1} messages
    You have 0 messages

But...

    bash$ echo You have $(expr $(frm >>> wc -l) - 1) messages
    bash: syntax error near unexpected token `>>>'
    bash: command substitution: line 1: `frm >>> wc -l'
    expr: syntax error
    You have messages

    rc; echo You have `{expr `{frm >>> wc -l} - 1} messages
    syntax error

Tim.
--
Tim Goodwin   | "[ `static' ] is so overloaded in the C/C++ world that
Leicester, UK | I try to avoid it whenever I can't." -- Larry Wall

Original headers:

From: tjg@star.le.ac.uk (Tim Goodwin)
Newsgroups: comp.unix.shell
Subject: Re: nested expr commands
Date: 11 Oct 1999 16:10:17 +0100
Organization: University of Leicester, UK
Message-ID: <7tsulf$tga$1@ltpcg.star.le.ac.uk>
References: <slrn7vq8qk.ue.ken@pulsar.halcyon.com>

△ comp.unix.shell △

◅ Processing non-empty stdout/stderr

nohup in ksh ▻