Re: bug#13389: echo command redhat linux OS
[adding the list] On 01/08/2013 11:01 AM, Bernhard Voelker wrote: Hi Eric, thanks, it seems like we understood Mohanad's question the same way ;-) On 01/08/2013 06:50 PM, Eric Blake wrote: join (join (cat -n one) (cat -n two)) (cat -n three) My join (Git latest) only accepts FILE1 and FILE2, but not a third file. Did I miss something? Yep - my level of parenthesis. Your solution is the same as mine in using two join processes, with the second using stdin produced by the output of the first; I just nested them via bash () process substitution instead of pipes. However, it does beg the question - is there any technical reason WHY join must not accept more than two files? It seems like that might be a nice GNU extension. -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature
Re: numfmt (=print 'human' sizes) updates
Hello, The attached patch adds 'numfmt' to the coreutils documentation. Regards, -gordon numfmt.12.patch.xz Description: application/xz
bug#13388: Date of 2012-10-21: invalid date. Bug?
Hi, When I try to get the date of 2012-10-21: root@cidLogin:~# date -d 20121021 date: invalid date `20121021' Is this a bug? The result is the same both in Opensuse Tumbleweed and Ubuntu 12.04. Thanks and sorry for disturbing, Danilo Luvizotto
bug#13389: echo command redhat linux OS
Dears Could we print values to be as three column ,each column present the values of each file. More explanation : I have three files ,each file include a queue of values .I need to print all the values by one command to be in one page Thanks [cid:image001.jpg@01CDECEE.BDCB6ED0] www.stc.com.sahttp://www.stc.com.sa/ Mohanad S. Azzam Senior Technical Engineer Content Adaptation System Operation dept. STC-B41 Contractor-RKe Technology P Please consider the environment before printing this e-mail. The information in this email may contain confidential material and it is intended solely for the addresses. Access to this email by anyone else is unauthorized. If you are not the intended recipient, please delete the email and destroy any copies of it, any disclosure, copying, distribution is prohibited and may be considered unlawful. Contents of this email and any attachments may be altered, Statement and opinions expressed in this email are those of the sender, and do not necessarily reflect those of Saudi Telecommunications Company (STC). inline: image001.jpg
bug#13388: Date of 2012-10-21: invalid date. Bug?
tag 13388 notabug thanks On 01/08/2013 06:02 AM, dan...@controlid.com.br wrote: Hi, When I try to get the date of 2012-10-21: root@cidLogin:~# date -d 20121021 date: invalid date `20121021' Is this a bug? No. It is a factor of daylight savings in your timezone. Midnight does not exist in your locale on that particular date. You can use --utc to force the use of times where daylight savings has no impact. For more information, see the FAQ: https://www.gnu.org/software/coreutils/faq/coreutils-faq.html#The-date-command-is-not-working-right_002e -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature
bug#13389: echo command redhat linux OS
tag 13389 notabug thanks On 01/08/2013 06:57 AM, Mohanad Azzam wrote: Dears Could we print values to be as three column ,each column present the values of each file. More explanation : I have three files ,each file include a queue of values .I need to print all the values by one command to be in one page Thanks Without a sample of your data, this sounds like you want to use join. Given you have the 3 files X, Y and Z with the following content: $ cat X 1 x1 2 x2 3 x3 $ cat Y 1 y1 2 y2 3 y3 $ cat Z 1 z1 2 z2 3 z3 If you don't have the line numbers, then you can easily create them with e.g. cat -n X. Then you can join X and Y (column 1 will be the key), and join the result (indicated by stdin -) with Z: $ join X Y | join - Z 1 x1 y1 z1 2 x2 y2 z2 3 x3 y3 z3 Have a nice day, Berny
bug#13389: echo command redhat linux OS
tag 13389 notabug thanks On 01/07/2013 10:57 PM, Mohanad Azzam wrote: Dears Could we print values to be as three column ,each column present the values of each file. More explanation : I have three files ,each file include a queue of values .I need to print all the values by one command to be in one page Rather than attempting to describe the problem, giving us an actual sample of three files, each containing three or so lines, as well as the desired output you want, would go a lot further in explaining the problem you really want solved. I will attempt to describe a setup that I think matches the wording you gave. I created three files: $ cat one 1 2 3 $ cat two a b c $ cat three x y z Then I can use something like this to merge those three files into a single listing with three columns, one entry from each file: $ join (join (cat -n one) (cat -n two)) (cat -n three) |\ sed 's/^[0-9]* *//' 1 a x 2 b y 3 c z There's probably other ways of doing it, as well. At any rate, your request is more of a usage question, and not an actual bug report. To avoid polluting the bug tracker with something that needs no further action in coreutils, I have marked this as not a bug. But you should still feel free to reply if you have further comments, or can provide more details about the real problem you are trying to solve. The information in this email may contain confidential material Unfortunately, it is now posted to a public archive, and this disclaimer is rendered unenforceable. For better netiquette, you may want to consider posting from a private account, rather than one where your employer tacks on lame legalese. -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature
bug#13389: echo command redhat linux OS
On Tue, 2013-01-08 at 10:50 -0700, Eric Blake wrote: tag 13389 notabug thanks On 01/07/2013 10:57 PM, Mohanad Azzam wrote: Dears Could we print values to be as three column ,each column present the values of each file. More explanation : I have three files ,each file include a queue of values .I need to print all the values by one command to be in one page Rather than attempting to describe the problem, giving us an actual sample of three files, each containing three or so lines, as well as the desired output you want, would go a lot further in explaining the problem you really want solved. I will attempt to describe a setup that I think matches the wording you gave. I created three files: $ cat one 1 2 3 $ cat two a b c $ cat three x y z Then I can use something like this to merge those three files into a single listing with three columns, one entry from each file: $ join (join (cat -n one) (cat -n two)) (cat -n three) |\ sed 's/^[0-9]* *//' 1 a x 2 b y 3 c z There's probably other ways of doing it, as well. Actually, pr -m -t -s' ' one two three seems to be easier to me for this case... Greetings, Ondrej
bug#13389: echo command redhat linux OS
On 01/08/2013 11:05 AM, Ondrej Vasik wrote: $ join (join (cat -n one) (cat -n two)) (cat -n three) |\ sed 's/^[0-9]* *//' 1 a x 2 b y 3 c z There's probably other ways of doing it, as well. Actually, pr -m -t -s' ' one two three seems to be easier to me for this case... Awesome trick - I would have never thought of pr. Should we mention pr(1) in the SEE ALSO of 'man join'? -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature
bug#13389: echo command redhat linux OS
On Tue, 2013-01-08 at 11:09 -0700, Eric Blake wrote: On 01/08/2013 11:05 AM, Ondrej Vasik wrote: $ join (join (cat -n one) (cat -n two)) (cat -n three) |\ sed 's/^[0-9]* *//' 1 a x 2 b y 3 c z There's probably other ways of doing it, as well. Actually, pr -m -t -s' ' one two three seems to be easier to me for this case... Awesome trick - I would have never thought of pr. Should we mention pr(1) in the SEE ALSO of 'man join'? Maybe, might be useful for someone - though I think this is more suitable for info documentation example/link... Greetings, Ondrej
bug#13391: dd silently ignores lseek error
Hi all, While trying to diagnose a weird filesystem bug, I found an error in GNU dd v8.12. The weird bug is causing lseek() to fail improperly. That's not the problem I'm reporting, though. I was trying to use dd to demonstrate the lseek error to my sysadmin. Instead, I found that dd is ignoring the lseek failure. Here is the relevant strace output: $ strace dd if=libdvapp-O.a of=/dev/null bs=33k skip=1 ... open(libdvapp-O.a, O_RDONLY) = 3 dup2(3, 0) = 0 close(3)= 0 lseek(0, 0, SEEK_CUR) = 0 open(/dev/null, O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3 dup2(3, 1) = 1 close(3)= 0 clock_gettime(CLOCK_MONOTONIC, {12951065, 389531862}) = 0 ioctl(0, MGSL_IOCSTXIDLE or MTIOCGET or SNDCTL_MIDI_MPUCMD, 0x7fbfffe3f0) = -1 ENOTTY (Inappropriate ioctl for device) lseek(0, 33792, SEEK_CUR) = -1 EINVAL (Invalid argument) ^ this is the syscall which should not be failing ioctl(0, MGSL_IOCSTXIDLE or MTIOCGET or SNDCTL_MIDI_MPUCMD, 0x7fbfffe3f0) = -1 ENOTTY (Inappropriate ioctl for device) lseek(0, 0, SEEK_END) = -1 EINVAL (Invalid argument) read(0, !arch\n/ 13576110..., 33792) = 33792 ... Note that it begins reading at the _beginning of the ar file_ -- the 'skip' argument has failed silently. The output of dd does not indicate any error: 3+1 records in 3+1 records out 103310 bytes (103 kB) copied, 0.000375 s, 275 MB/s Expected behavior: dd should pass on any unexpected errors reported by system calls. I realize this is an old version of coreutils but I don't have a newer version available to test against the anomaly. Sorry if it's already been fixed. Regards, --Neil
bug#13391: dd silently ignores lseek error
On 01/08/13 10:11, Neil Klopfenstein wrote: Note that it begins reading at the _beginning of the ar file_ -- the 'skip' argument has failed silently. But the 'skip' hasn't failed. It's merely being implemented via 'read' rather than via 'lseek'. The records are being skipped correctly. It might be useful to give dd a new option, which causes it to insist on lseeking rather than reading in cases like these, and to report an error if the lseek fails.
bug#13391: dd silently ignores lseek error
On 01/08/2013 08:55 PM, Paul Eggert wrote: On 01/08/13 10:11, Neil Klopfenstein wrote: Note that it begins reading at the _beginning of the ar file_ -- the 'skip' argument has failed silently. But the 'skip' hasn't failed. It's merely being implemented via 'read' rather than via 'lseek'. The records are being skipped correctly. It might be useful to give dd a new option, which causes it to insist on lseeking rather than reading in cases like these, and to report an error if the lseek fails. I had a look around for a tool to verify that a file/device supports the seek operation and couldn't find one. So this seems like useful functionality. Worth applying the attached? thanks, Pádraig. From ea524ab7388bb35e591dcdb0fc7f7989d61143ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draig=20Brady?= p...@draigbrady.com Date: Wed, 9 Jan 2013 00:42:38 + Subject: [PATCH] dd: add [io]flag=seekable to verify file support for lseek * src/dd.c: Add the new O_SEEKABLE flag. (main): Verify leek() works if O_SEEKABLE is set. (usage): Describe the new flag. * tests/dd/misc.sh: Augment the test for the new options. * doc/coreutils.texi (dd invocation): Describe the new option. * cfg.mk (sc_dd_O_FLAGS): Add O_SEEKABLE to the list of private flags with a a single underscore. * NEWS: Mention the new feature. Suggested by Paul Eggert in http://bugs.gnu.org/13391 --- NEWS |3 +++ cfg.mk |2 +- doc/coreutils.texi |6 ++ src/dd.c | 28 +++- tests/dd/misc.sh |8 5 files changed, 45 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 754b2cf..9c415ec 100644 --- a/NEWS +++ b/NEWS @@ -4,6 +4,9 @@ GNU coreutils NEWS-*- outline -*- ** New features + dd now accepts 'iflag=seekable' and 'oflag=seekable' to verify that the + corresponding files support the seek operation. + df now accepts the --output[=FIELD_LIST] option to define the list of columns to include in the output, or all available columns if the FIELD_LIST is omitted. Note this enables df to output both block and inode fields together. diff --git a/cfg.mk b/cfg.mk index fbc64b4..bf43861 100644 --- a/cfg.mk +++ b/cfg.mk @@ -57,7 +57,7 @@ _hv_file ?= $(srcdir)/tests/misc/help-version dd = $(srcdir)/src/dd.c sc_dd_O_FLAGS: @rm -f $@.1 $@.2 - @{ echo O_FULLBLOCK; echo O_NOCACHE;\ + @{ echo O_FULLBLOCK; echo O_NOCACHE; echo O_SEEKABLE; \ perl -nle '/^ +\| (O_\w*)$$/ and print $$1' $(dd); } | sort $@.1 @{ echo O_NOFOLLOW; perl -nle '/{[a-z]+,\s*(O_\w+)},/ and print $$1' \ $(dd); } | sort $@.2 diff --git a/doc/coreutils.texi b/doc/coreutils.texi index 45a4b3d..9ee9d86 100644 --- a/doc/coreutils.texi +++ b/doc/coreutils.texi @@ -8399,6 +8399,12 @@ rather than a block count, which allows specifying an offset that is not a multiple of the I/O block size. This flag can be used only with @code{oflag}. +@item seekable +@opindex seekable +Fail unless the file is seekable. +Note @samp{skip=} or @samp{seek=} don't suffice for this check, +as they will resort to reading, to skip over data. + @end table These flags are not supported on all systems, and @samp{dd} rejects diff --git a/src/dd.c b/src/dd.c index ef5664b..21b4b21 100644 --- a/src/dd.c +++ b/src/dd.c @@ -216,6 +216,9 @@ static xtime_t start_time; /* True if input is seekable. */ static bool input_seekable; +/* True if output is seekable. */ +static bool output_seekable; + /* Error number corresponding to initial attempt to lseek input. If ESPIPE, do not issue any more diagnostics about it. */ static int input_seek_errno; @@ -326,7 +329,10 @@ enum O_SKIP_BYTES = FFS_MASK (v4), v5 = v4 ^ O_SKIP_BYTES, -O_SEEK_BYTES = FFS_MASK (v5) +O_SEEK_BYTES = FFS_MASK (v5), +v6 = v5 ^ O_SEEK_BYTES, + +O_SEEKABLE = FFS_MASK (v6) }; /* Ensure that we got something. */ @@ -335,6 +341,7 @@ verify (O_NOCACHE != 0); verify (O_COUNT_BYTES != 0); verify (O_SKIP_BYTES != 0); verify (O_SEEK_BYTES != 0); +verify (O_SEEKABLE != 0); #define MULTIPLE_BITS_SET(i) (((i) ((i) - 1)) != 0) @@ -344,6 +351,7 @@ verify ( ! MULTIPLE_BITS_SET (O_NOCACHE)); verify ( ! MULTIPLE_BITS_SET (O_COUNT_BYTES)); verify ( ! MULTIPLE_BITS_SET (O_SKIP_BYTES)); verify ( ! MULTIPLE_BITS_SET (O_SEEK_BYTES)); +verify ( ! MULTIPLE_BITS_SET (O_SEEKABLE)); /* Flags, for iflag=... and oflag= */ static struct symbol_value const flags[] = @@ -366,6 +374,7 @@ static struct symbol_value const flags[] = {count_bytes, O_COUNT_BYTES}, {skip_bytes, O_SKIP_BYTES}, {seek_bytes, O_SEEK_BYTES}, + {seekable,O_SEEKABLE}, {, 0} }; @@ -619,6 +628,9 @@ Each FLAG symbol may be:\n\ if (O_SEEK_BYTES) fputs (_( seek_bytes treat 'seek=N' as a byte count (oflag only)\n\ ), stdout); + if (O_SEEKABLE) +fputs (_( seekable fail unless seekable\n\ +), stdout); { char const
bug#13391: dd silently ignores lseek error
On 01/08/2013 05:14 PM, Pádraig Brady wrote: Worth applying the attached? Looks good, except I would avoid calling lseek on STDOUT_FILENO unless oflag=seekable is set. Just being conservative: the effect of lseek on unseekable files is implementation-defined.
bug#13391: dd silently ignores lseek error
Hi, On Wed, Jan 09, 2013 at 01:14:22AM +, Pádraig Brady wrote: On 01/08/2013 08:55 PM, Paul Eggert wrote: On 01/08/13 10:11, Neil Klopfenstein wrote: Note that it begins reading at the _beginning of the ar file_ -- the 'skip' argument has failed silently. But the 'skip' hasn't failed. It's merely being implemented via 'read' rather than via 'lseek'. The records are being skipped correctly. It might be useful to give dd a new option, which causes it to insist on lseeking rather than reading in cases like these, and to report an error if the lseek fails. I had a look around for a tool to verify that a file/device supports the seek operation and couldn't find one. So this seems like useful functionality. Worth applying the attached? [...] * src/dd.c: Add the new O_SEEKABLE flag. (main): Verify leek() works if O_SEEKABLE is set. ^^lseek() [...] /* else file_size offset OFF_T_MAX or file ! seekable */ + Stray new newline? do [...] Besides these nitpicks the patch looks good to me. HTH, Erik
bug#13391: dd silently ignores lseek error
On 01/09/2013 02:14 AM, Pádraig Brady wrote: I had a look around for a tool to verify that a file/device supports the seek operation and couldn't find one. So this seems like useful functionality. Worth applying the attached? * cfg.mk (sc_dd_O_FLAGS): Add O_SEEKABLE to the list of private flags with a a single underscore. s/a a/a/ @@ -619,6 +628,9 @@ Each FLAG symbol may be:\n\ if (O_SEEK_BYTES) fputs (_( seek_bytes treat 'seek=N' as a byte count (oflag only)\n\ ), stdout); + if (O_SEEKABLE) +fputs (_( seekable fail unless seekable\n\ +), stdout); no line break needed here. + offset = lseek (STDOUT_FILENO, 0, SEEK_CUR); + output_seekable = (0 = offset); + if (! input_seekable (input_flags O_SEEKABLE)) +{ + error (EXIT_FAILURE, input_seek_errno, _(input is not seekable %s), + quote (input_file)); +} why not check input_seekable where it is set - ~60 lines above? Have a nice day, Berny