dash.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Harald van Dijk <harald@gigawatt.nl>
To: Kylie McClain <somasissounds@gmail.com>, dash@vger.kernel.org
Cc: Kylie McClain <somasis@exherbo.org>
Subject: Re: [PATCH 1/2] mkbuiltins: Use a `while` loop rather than `nl`
Date: Sat, 6 Aug 2016 18:51:28 +0200	[thread overview]
Message-ID: <60024a83-638d-5354-84d0-85ce96c1ec65@gigawatt.nl> (raw)
In-Reply-To: <be6ddf83-041e-7dca-5f5c-16167faa9d95@gigawatt.nl>

On 04/08/2016 19:17, Harald van Dijk wrote:
> On 04/08/2016 07:54, Kylie McClain wrote:
>> From: Kylie McClain <somasis@exherbo.org>
>> nl, while specified in POSIX, is rather obscure and isn't provided by
>> small
>> coreutils implementations such as `busybox`. This while loop works
>> just as
>> well for our purposes.
> ...
>> -sed 's/    -[a-z]*//' $temp2 | nl -ba -v0 |
>> +sed 's/    -[a-z]*//' $temp2 | while read line;do \
>> +    i=$(( ${i:--1} + 1 )); printf '%s %s\n' "${i}" "${line}";done |
> $(( ... )) is mentioned in
> <https://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/Shell-Substitutions.html>
> as not universally supported, notably Solaris 10 /bin/sh does not have
> it. Given that dash was fairly recently changed to make it build on
> Solaris 9, it seems like a mistake to break that again.

I just realised that that particular change to make it build on Solaris 
9 involved avoiding running mkbuiltins using sh, choosing to use $SHELL 
instead, as $SHELL should already have been picked by configure as 
something more modern. So the use of $(( ... )) should probably not be a 
problem after all...

> Aside from that, i is such a common variable name that it seems risky to
> assume it is unset. I know I've set it myself in shell sessions that I
> ended up using for building dash. I never exported it, so it wouldn't
> break here, but it doesn't seem like a stretch that someone else does
> export it.

...as long as i is simply initialised before the loop.

Harald van Dijk

  parent reply	other threads:[~2016-08-06 21:59 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-04  5:54 Kylie McClain
2016-08-04  5:54 ` [PATCH 2/2] histedit: Remove non-glibc fallback code Kylie McClain
2016-08-04 15:59   ` Jilles Tjoelker
2016-08-08 15:50     ` Jilles Tjoelker
2016-08-04 17:17 ` [PATCH 1/2] mkbuiltins: Use a `while` loop rather than `nl` Harald van Dijk
2016-08-06  9:02   ` Seb
2016-08-07 10:17     ` Seb
2016-08-06 16:51   ` Harald van Dijk [this message]
2016-08-08 15:33   ` Herbert Xu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=60024a83-638d-5354-84d0-85ce96c1ec65@gigawatt.nl \
    --to=harald@gigawatt.nl \
    --cc=dash@vger.kernel.org \
    --cc=somasis@exherbo.org \
    --cc=somasissounds@gmail.com \
    --subject='Re: [PATCH 1/2] mkbuiltins: Use a `while` loop rather than `nl`' \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).