coreutils
[Top][All Lists]
Advanced

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

Re: [PATCH] scripts: rewrite dcgen in shellscript


From: Jeffrey Walton
Subject: Re: [PATCH] scripts: rewrite dcgen in shellscript
Date: Wed, 29 May 2024 04:38:24 -0400

On Wed, May 29, 2024 at 4:02 AM Rob Landley <rob@landley.net> wrote:
>
> On 5/27/24 11:21, Pádraig Brady wrote:
>  [...]
> > BTW in regard to ensuring GNU sed is invoked, supporting overriding
> > the called sed with a $SED env var would be useful.
>
> 20 years ago;
>
> http://lists.busybox.net/pipermail/busybox/2004-January/044644.html
>
> (Meanwhile https://github.com/landley/toybox/issues/461 is because I didn't
> initially notice because the eldrich horror that is autoconf traverses the 
> $PATH
> to find a _second_ instance of commands to silently use the wrong one if it
> decides it doesn't like the first one, and thus I need to redesign my test
> environment to to lie to autoconf and hide data from it EVEN HARDER...)

It would be useful to allow a SED override without twiddling with PATHs.

Solaris puts an anemic (Posix) sed on path. Solaris provides GNU sed,
but it is tucked away in /usr/gnu/bin (and not on path by default).
Setting SED=/usr/gnu/bin/sed is standard for some scripts. Even if
there is a newer sed elsewhere, the one at /usr/gnu/bin can usually
accomplish just about everything that needs to be done.

The same applies to AWK and GREP on Solaris, too. Here's what one of
my scripts looks like, with SOlaris workarounds because I use GNU
extensions.

GREP="${GREP:-"$(command -v grep 2>/dev/null)"}"
EGREP="${EGREP:-"$(command -v grep 2>/dev/null) -E"}"
SED="${SED:-"$(command -v sed 2>/dev/null)"}"
AWK="${AWK:-"$(command -v awk 2>/dev/null)"}"

# Non-anemic tools on Solaris
if [[ -d /usr/gnu/bin ]]; then
    GREP="/usr/gnu/bin/grep"
    EGREP="/usr/gnu/bin/grep -E"
    SED="/usr/gnu/bin/sed"
    AWK="/usr/gnu/bin/awk"
elif [[ -d /usr/sfw/bin ]]; then
    GREP="/usr/sfw/bin/grep"
    EGREP="/usr/sfw/bin/grep -E"
    SED="/usr/sfw/bin/sed"
    AWK="/usr/sfw/bin/awk"
fi

Jeff



reply via email to

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