zsh
でシェルスクリプトを書いているのですが、mapfile
コマンドが使えません。
mac標準のシェルに含まれていないのかと考え、homebrewで最新版のものをインストールしました。
ですが、which zsh
や$PATH
ではbrew経由のものが優先されているにも関わらず、zsh --version
の結果を見る限りApple謹製のものを認識しているようです。
brewでインストールしたbash
も同様に、Appleのものが認識されており、readarray
コマンドが使えません。
パスの問題かと思うのですが、どうすれば良いでしょうか?
terminal
1❯ echo $PATH 2/usr/local/opt/llvm/bin:/usr/local/opt/curl/bin:/usr/local/opt/python@3.8/bin:/Users/solzard/.poetry/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin::/usr/sbin:/sbin:/opt/X11/bin 3 4~ 5❯ which zsh 6/usr/local/bin/zsh 7 8~ 9❯ whereis zsh 10/bin/zsh 11 12~ 13❯ zsh --version 14zsh 5.8 (x86_64-apple-darwin18.7.0) 15 16~ 17❯ brew info zsh 18zsh: stable 5.8 (bottled), HEAD 19UNIX shell (command interpreter) 20https://www.zsh.org/ 21/usr/local/Cellar/zsh/5.8 (1,531 files, 13.5MB) * 22 Poured from bottle on 2020-02-25 at 23:14:16 23From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/zsh.rb 24==> Dependencies 25Required: ncurses ✔, pcre ✔ 26==> Options 27--HEAD 28 Install HEAD version 29==> Analytics 30install: 75,949 (30 days), 143,477 (90 days), 520,776 (365 days) 31install-on-request: 70,817 (30 days), 135,088 (90 days), 496,084 (365 days) 32build-error: 0 (30 days) 33 34~ 35❯ which bash 36/usr/local/bin/bash 37 38~ 39❯ whereis bash 40/bin/bash 41 42~ 43❯ bash --version 44GNU bash, version 5.0.16(1)-release (x86_64-apple-darwin18.7.0) 45Copyright (C) 2019 Free Software Foundation, Inc. 46License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> 47 48This is free software; you are free to change and redistribute it. 49There is NO WARRANTY, to the extent permitted by law. 50 51~ 52❯ brew info bash 53bash: stable 5.0.16 (bottled), HEAD 54Bourne-Again SHell, a UNIX command interpreter 55https://www.gnu.org/software/bash/ 56/usr/local/Cellar/bash/5.0.16 (150 files, 9.4MB) * 57 Poured from bottle on 2020-03-15 at 15:42:16 58From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/bash.rb 59==> Options 60--HEAD 61 Install HEAD version 62==> Analytics 63install: 30,645 (30 days), 71,983 (90 days), 307,568 (365 days) 64install-on-request: 24,936 (30 days), 59,140 (90 days), 250,747 (365 days) 65build-error: 0 (30 days) 66
追記 (動かないスクリプト, zshrcの関連部分, zmodloadの出力)
zsh
1#!/usr/local/bin/zsh 2urls=" 3https://www.youtube.com/watch?v=sample1 4https://www.youtube.com/watch?v=sample2 5https://www.youtube.com/watch?v=sample3 6" 7echo "$urls" 8mapfile -t parsed_urls <<< "$urls" # download.sh:8: command not found: mapfileとなる 9 10for url in "${parsed_urls[@]}"; do 11 echo "$url" 12 youtube-dl "$url" 13 printf "\n" 14done
zshrc
1... 2# enable mapfile 3zmodload zsh/mapfile 4...
terminal
1❯ zmodload 2zsh/complete 3zsh/complist 4zsh/computil 5zsh/datetime 6zsh/main 7zsh/mapfile 8zsh/parameter 9zsh/regex 10zsh/terminfo 11zsh/zle 12zsh/zleparameter 13zsh/zpty 14zsh/zutil 15
回答2件
あなたの回答
tips
プレビュー