0
ループ外の2つの隠しファイルを開こうとすると、下の2番目のコードブロックのselect文には表示されません。bashは、ループ内の選択内の隠しファイルを開くことができません
#!/bin/bash
bbedit "./.bashrc"; # works fine here
bbedit "./.bash_profile"; # works fine here
ただし、どちらもselect文で失敗します。私はshoptを使ってみたが、それは役に立たなかった。
#!/bin/bash
divider="-----------------------------------------------------------------"
echo -n "Admin "
sudo echo
echo
echo $divider
echo "| Enter an item number to open the following? |"
echo "| When done opening the files, enter the choice for ALL DONE |"
echo $divider
echo
shopt -s dotglob
done_flag="begin"
while [ "$done_flag" != "end" ];do
select item in "apache" "hosts" "php.ini" "~/.bash_profile" "~/.bashrc" "ALL DONE"; do
case $item in
apache)
sudo bbedit "/etc/apache2/httpd.conf";
break;;
hosts)
sudo bbedit "/etc/hosts";
break;;
php.ini)
sudo bbedit "/etc/php.ini";
break;;
~/.bash_profile) # quotes here will fix the case statement
bbedit "./.bash_profile"; # hidden file will not open inside loop
break;;
~/.bashrc) # quotes here will fix the case statement
bbedit "./.bashrc"; # hidden file will not open inside loop
break;;
"ALL DONE")
done_flag="end";
break;;
esac
done
done
shopt -u dotglob
exit 0
引用符があります。私はあなたが何を意味するかを見ます... –