最初のbashスクリプトを試しています。複製されたリポジトリを保存する場所をユーザーに尋ねるメッセージを表示したいと思います。
現在はこのように割り当てています。
warpToLocation="${HOME}/apps/"
これを行う方法はありますか?
read -e -p "Enter the path to the file: " -i "${HOME}/apps/" FILEPATH
しかし、結果は次のように保存しますかwarpToLocation
?
編集する:
#!/bin/bash
echo "where would you like to install your repos?"
read -p "Enter the path to the file: " temp
warpToLocation="${HOME}/$temp/"
warpInLocations=("[email protected]:cca/toolkit.git" "[email protected]:cca/sms.git" "[email protected]:cca/boogle.git" "[email protected]:cca/cairo.git")
echo "warping in toolkit, sms, boogle and cairo"
for repo in "${warpInLocations[@]}"
do
warpInDir=$repo
warpInDir=${warpInDir#*/}
warpInDir=${warpInDir%.*}
if [ -d "$warpToLocation"]; then
echo "somethings in the way.. $warpInDir all ready exists"
else
git clone $repo $warpInDir
fi
done
そのエラーを得るために私がしたことは、あなたが私に与えたコードを追加することだけでした。
問題は、-e
(矢印で入力を編集できる)と-i
(プレビュー/代替回答)がbashバージョン4以降で実行され、バージョン2を実行していることですGNU bash, version 3.2.48(1)-release (x86_64-apple-darwin12)
。
ベストアンサー1
何が間違っていますか?
read -e -p "Enter the path to the file: " -i "${HOME}/apps/" warpToLocation
?