0
私はラテックスファイル間のバージョン変更の確認を合理化する小さなスクリプトを作成しようとしています。このスクリプトでは、git show
を使ってファイルの指定されたバージョンを取得していますが、問題が発生しています。ここでgit showがBASHスクリプトで動作しない
は、これまでのところ、私のスクリプトです:
#!/bin/bash
# A cl interface to compare changes between git versions of a latex doc
# Select tex file to examine
tex1=$(ls *.tex| slmenu -p "Select a tex file: ")
## Select branch
branches=$(git branch | cut -c3-)"\nHEAD"
branch=$(echo $branches | slmenu -p "Select the branch to compare to:")
# Select how many steps ago
echo "How far back? (see git reflog)"
read steps
treeish=$(echo $branch'~'$steps":'"$tex1"'")
echo "Will compare to this branch position:"
echo $treeish
git show $treeish > temp.tex
私がテストしていたファイルは、空白文字があります。コードを実行している場合は、ここでエラーと一緒にフル出力です:私はエコーの結果をコピーする場合、しかし、git show $treeish > temp.tex
を実行しようとしたときにエラーがライン21で行わ
Select a tex file: SMART Reporting Tutorials.tex SMART Reporting Tutorials.tex
Select the branch to compare to: HEAD HEAD
How far back? (see git reflog)
1
Will compare to this branch position:
HEAD~1:'SMART Reporting Tutorials.tex'
fatal: Path ''SMART' does not exist in 'HEAD~1'
、 HEAD~1:'SMART Reporting Tutorials.tex'
は、とgit show:
git show HEAD:'SMART Reporting Tutorials.tex'
私はそれがうまく動作することを確認します。だから私は私の質問は、推測です...なぜ私はBASHスクリプトで失敗しますが、私は端末にそれを入力すると正常に動作しますか?
ワンダフル!!これはそれを修正しました! –
これについての詳しい説明は... [this post](http://stackoverflow.com/questions/10067266/when-to-wrap-quotes-around-a-variable)への答えは、これについての良い説明です。 –