Skip to content

問題140 別解1 は Ubuntu 24.04 等の yes ではエラーになる #73

@ktrarai

Description

@ktrarai

本件もご執筆時の環境 Ubuntu 20.04 では正常動作することはこちらでも確認しておりますが、一応、報告させていただきます。

$ yes --version
yes (GNU coreutils) 9.4
...
$ yes paste -d . '<(shuf -n1 -e {1..254})'{,,,} | head -n 100 | bash
yes: invalid option -- 'd'
Try 'yes --help' for more information.

release 8.31 から yes 等の動作に変更があった模様です。 (Ubuntu 20.04 では yes (GNU coreutils) 8.30 。)

$ zless /usr/share/doc/coreutils/NEWS.gz

* Noteworthy changes in release 8.31 (2019-03-10) [stable]
...
** Changes in behavior

  cksum, dd, hostid, hostname, link, logname, sleep, tsort, unlink,
  uptime, users, whoami, yes: now always process --help and --version options,
  regardless of any other arguments present before any optional '--'
  end-of-options marker.

  nohup now processes --help and --version as first options even if other
  parameters follow.

  'yes a -- b' now outputs 'a b' instead of including the end-of-options
  marker as before: 'a -- b'.

というわけで、 Ubuntu 24.04 等でも正常実行させるには

$ yes 'paste -d .' '<(shuf -n1 -e {1..254})'{,,,} | head -n 100 | bash

または

$ yes -- paste -d . '<(shuf -n1 -e {1..254})'{,,,} | head -n 100 | bash

または

$ yes () { if [[ "$1" = -* ]]; then command yes "$@"; else command yes -- "$@"; fi; }; export -f yes
$ yes paste -d . '<(shuf -n1 -e {1..254})'{,,,} | head -n 100 | bash

などとする必要がありました。

以上、あくまでもご参考としての報告でした。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions