DASH Shell discussions
 help / color / mirror / Atom feed
* Porting dash to OpenBSD
@ 2011-06-26  2:18 Mike Korbakov
  2011-07-03 20:54 ` Jilles Tjoelker
  2011-07-08  8:58 ` Herbert Xu
  0 siblings, 2 replies; 3+ messages in thread
From: Mike Korbakov @ 2011-06-26  2:18 UTC (permalink / raw)
  To: dash

Hello!

Unfortunatly, not all systems (like OpenBSD) has built-in texttools like nl,
that makes it difficult to port dash, with minimum troubles.

To reduce dependencies, I suggest using instead of nl other tools like awk or cat
(as advised openbsd porters team).

Building dash-0.5.6.1 was successfull with this patch:

--- src/mkbuiltins.orig Sat Jun  5 13:34:23 2010
+++ src/mkbuiltins      Sun Jun 26 02:36:23 2011
@@ -84,7 +84,7 @@ cat <<\!
  */

 !
-sed 's/        -[a-z]*//' $temp2 | nl -v 0 | LC_COLLATE=C sort -u -k 3,3 |
+sed 's/        -[a-z]*//' $temp2 | awk '{ print "  " FNR-1 "  " $0 }'  | LC_COLLATE=C sort -u -k 3,3 |
 tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ |
        awk '{  printf "#define %s (builtincmd + %d)\n", $3, $1}'
 printf '\n#define NUMBUILTINS %d\n' $(wc -l < $temp2)


Would you make these changes in future releases?

Best regards,
Mike Korbakov.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Porting dash to OpenBSD
  2011-06-26  2:18 Porting dash to OpenBSD Mike Korbakov
@ 2011-07-03 20:54 ` Jilles Tjoelker
  2011-07-08  8:58 ` Herbert Xu
  1 sibling, 0 replies; 3+ messages in thread
From: Jilles Tjoelker @ 2011-07-03 20:54 UTC (permalink / raw)
  To: Mike Korbakov; +Cc: dash

On Sun, Jun 26, 2011 at 06:18:59AM +0400, Mike Korbakov wrote:
> Unfortunatly, not all systems (like OpenBSD) has built-in texttools
> like nl, that makes it difficult to port dash, with minimum troubles.

> To reduce dependencies, I suggest using instead of nl other tools like
> awk or cat (as advised openbsd porters team).

> Building dash-0.5.6.1 was successfull with this patch:

> --- src/mkbuiltins.orig Sat Jun  5 13:34:23 2010
> +++ src/mkbuiltins      Sun Jun 26 02:36:23 2011
> @@ -84,7 +84,7 @@ cat <<\!
>   */
> 
>  !
> -sed 's/        -[a-z]*//' $temp2 | nl -v 0 | LC_COLLATE=C sort -u -k 3,3 |
> +sed 's/        -[a-z]*//' $temp2 | awk '{ print "  " FNR-1 "  " $0 }'  | LC_COLLATE=C sort -u -k 3,3 |
>  tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ |
>         awk '{  printf "#define %s (builtincmd + %d)\n", $3, $1}'
>  printf '\n#define NUMBUILTINS %d\n' $(wc -l < $temp2)

This looks reasonable. It works here (FreeBSD with somewhat hacked dash
source), leaving the resulting binary unchanged.

A minor nit: comparing with other awk invocations, it seems more usual
to use NR rather than FNR. They both do the same thing if there is only
one input file.

The nl utility has caused more portability problems already; the code in
master has different options. This is so even though nl is in SUSv4
under the XSI option. We already use awk so that should be safer.

-- 
Jilles Tjoelker

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Porting dash to OpenBSD
  2011-06-26  2:18 Porting dash to OpenBSD Mike Korbakov
  2011-07-03 20:54 ` Jilles Tjoelker
@ 2011-07-08  8:58 ` Herbert Xu
  1 sibling, 0 replies; 3+ messages in thread
From: Herbert Xu @ 2011-07-08  8:58 UTC (permalink / raw)
  To: Mike Korbakov; +Cc: dash

On Sun, Jun 26, 2011 at 02:18:59AM +0000, Mike Korbakov wrote:
> Hello!
> 
> Unfortunatly, not all systems (like OpenBSD) has built-in texttools like nl,
> that makes it difficult to port dash, with minimum troubles.

Hmm, nl is part of POSIX and dash is supposed to be a POSIX shell.

Cheers,
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-07-08  8:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-26  2:18 Porting dash to OpenBSD Mike Korbakov
2011-07-03 20:54 ` Jilles Tjoelker
2011-07-08  8:58 ` Herbert Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox