Re: portable use of 'dd'

View: New views
5 Messages — Rating Filter:   Alert me  

Parent Message unknown Re: portable use of 'dd'

by Bruno Haible :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi GNU standards maintainers,

Jim Meyering wrote in [1]
> use dd ibs=$n count=1 ... rather than less-portable head -c$n

The GNU standards, section "Utilities in Makefiles", do not mention 'dd'
among the list of utilities whose existence can be assumed everywhere.

But on all platforms that I tested (including old ones like IRIX 6.5, OSF/1 4.0,
Solaris 2.5.1), 'dd' exists, and
  $ echo abcdef | dd ibs=4 count=1 2>/dev/null; echo
yields the output
  abcd

Therefore I would suggest to add 'dd' among the "safe" utilities.

--- doc/make-stds.texi.orig 2008-05-14 23:15:34.000000000 +0200
+++ doc/make-stds.texi 2008-05-14 23:15:17.000000000 +0200
@@ -160,7 +160,7 @@
 @c mkfifo mknod tee uname
 
 @example
-awk cat cmp cp diff echo egrep expr false grep install-info
+awk cat cmp cp dd diff echo egrep expr false grep install-info
 ln ls mkdir mv pwd rm rmdir sed sleep sort tar test touch true
 @end example
 

Bruno


[1] http://lists.gnu.org/archive/html/bug-gnulib/2008-05/msg00067.html




Re: portable use of 'dd'

by Karl Berry :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

    Therefore I would suggest to add 'dd' among the "safe" utilities.

Granted that dd is certainly more portable than head -c, are we now
using it in configure/make such that it has to be listed in the coding
standards node?

I've never thought of that list in Utilities in Makefiles as being all
"utilities whose existence can be assumed everywhere", but rather
"utilities which need to exist to bootstrap a system".




Re: portable use of 'dd'

by Paul Eggert :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

karl@... (Karl Berry) writes:

> I've never thought of that list in Utilities in Makefiles as being all
> "utilities whose existence can be assumed everywhere", but rather
> "utilities which need to exist to bootstrap a system".

In practice I think it means "utilities whose existence are needed to
run 'configure' and 'make'".  (Somewhere between the two, as one could
in theory bootstrap by first building coreutils.)

This particular case is only weak evidence that 'dd' needs to be in
the list, since the code uses 'dd' only when /dev/urandom is readable,
and I expect that 'dd' is supported everywhere /dev/urandom is.



Re: portable use of 'dd'

by Karl Berry :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

    This particular case is only weak evidence that 'dd' needs to be in
    the list, since the code uses 'dd' only when /dev/urandom is readable,
    and I expect that 'dd' is supported everywhere /dev/urandom is.

So, I'm inclined to do nothing.  /dev/urandom is surely less portable
than dd, so there seems to be no point.

k



Re: portable use of 'dd'

by Bruno Haible :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Paul Eggert wrote:
>     This particular case is only weak evidence that 'dd' needs to be in
>     the list, since the code uses 'dd' only when /dev/urandom is readable,
>     and I expect that 'dd' is supported everywhere /dev/urandom is.

On the other hand, can you point out a system which does not support 'dd'?
You make it sound as if *not* having 'dd' in the list would help portability
to some platforms. Which platforms?

Bruno