とんちゃんといっしょ

Cloudに関する技術とか日常とかについて書いたり書かなかったり

base64のオプション

某所で base64 -D と書いてあったのでそのまま打ったらエラーになってあれーと思ったはなし。

$ base64 -D
base64: invalid option -- 'D'
Try 'base64 --help' for more information.

自分の記憶では -D で動いたはずなんだけどと思って調べてみた。

Ubuntu

$ man base64
BASE64(1)                                                 User Commands                                                 BASE64(1)

NAME
       base64 - base64 encode/decode data and print to standard output

SYNOPSIS
       base64 [OPTION]... [FILE]

DESCRIPTION
       Base64 encode or decode FILE, or standard input, to standard output.

       With no FILE, or when FILE is -, read standard input.

       Mandatory arguments to long options are mandatory for short options too.

       -d, --decode
              decode data

Mac

$ man base64
base64(1)                 BSD General Commands Manual                base64(1)

NAME
     base64 -- Encode and decode using Base64 representation

SYNOPSIS
     base64 [-h | -D] [-b count] [-i input_file] [-o output_file]

DESCRIPTION
     base64 encodes and decodes Base64 data, as specified in RFC 4648. With no options, base64 reads raw data from
     stdin and writes encoded data as a continuous block to stdout.

OPTIONS
     The following options are available:
     -b count
     --break=count        Insert line breaks every count characters. Default is 0, which generates an unbroken stream.

     -D
     --decode             Decode incoming Base64 stream into binary data.

LinuxBSD系でオプションが大文字小文字が違うという問題だったらしい。

とりあえず --decode オプションにすればどっちでも動くので解決。

それを見つけたドキュメントはPRも投げておいた

github.com