Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.bugs.dist > #1011758 > unrolled thread

Bug#961739: printf attempts to parse options and fails to print -h or similar

Started byMelvin Vermeeren <vermeeren@vermwa.re>
First post2020-05-28 17:30 +0200
Last post2020-05-29 20:00 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.debian.bugs.dist


Contents

  Bug#961739: printf attempts to parse options and fails to print -h or similar Melvin Vermeeren <vermeeren@vermwa.re> - 2020-05-28 17:30 +0200
    Bug#961739: printf attempts to parse options and fails to print -h or similar Jakub Wilk <jwilk@jwilk.net> - 2020-05-29 20:00 +0200

#1011758 — Bug#961739: printf attempts to parse options and fails to print -h or similar

FromMelvin Vermeeren <vermeeren@vermwa.re>
Date2020-05-28 17:30 +0200
SubjectBug#961739: printf attempts to parse options and fails to print -h or similar
Message-ID<AbsDM-5yg-7@gated-at.bofh.it>

[Multipart message — attachments visible in raw view] — view raw

Package: dash
Version: 0.5.10.2-5

Hi,

POSIX specifies printf has no options, meaning these should print "-h" and "--
help" respectively. Arguments parsing must simply not be attempted at all in 
order to be compliant as far as I know.

$ printf -h
sh: 1: printf: Illegal option -h
$ printf --help
sh: 2: printf: Illegal option --

From https://pubs.opengroup.org/onlinepubs/9699919799/utilities/printf.html:
> SYNOPSIS
>
>    printf format [argument...]
>
> ...
>
> OPTIONS
>
>    None.

Bash also does not handle this correctly. However bash is not POSIX sh, hence 
it is not a bug. (It appears bash some some "printf -v var" extension.) I also 
tested zsh, which appears to be fully compliant.

Thanks

-- 
Melvin Vermeeren

[toc] | [next] | [standalone]


#1011914

FromJakub Wilk <jwilk@jwilk.net>
Date2020-05-29 20:00 +0200
Message-ID<AbRsu-3uE-3@gated-at.bofh.it>
In reply to#1011758
* Melvin Vermeeren <vermeeren@vermwa.re>, 2020-05-28, 17:17:
>POSIX specifies printf has no options, meaning these should print "-h" 
>and "--help" respectively. Arguments parsing must simply not be 
>attempted at all in order to be compliant as far as I know.

As I wrote in #961740, I think you're misinterpreting the standard.

>I also tested zsh, which appears to be fully compliant.

Let's see:

   % printf -v
   printf: argument expected: -v

-- 
Jakub Wilk

[toc] | [prev] | [standalone]


Back to top | Article view | linux.debian.bugs.dist


csiph-web