shell script에서 double quotation 관련 질문

sunnyncom의 이미지

스크립트 내부에서 double quoatation 을 그대로 사용할 수 있는 방법이 있는지요?

예를 들면 mygit이라는 스크립트를 만들어서 아래와 같이 사용한다고 가정할 때

mygit log --pretty=format:"%h - %an, %ar : %s"

mygit 이라는 스크립트에서는 log --pretty=format:"%h - %an, %ar : %s" 부분을 그대로 다시 git으로 넘어가는

파라미터로 재사용 하고 싶습니다.

예를 들면 아래와 같이 변수에 대입하면

param=$2

param에는 --pretty=format:"%h - %an, %ar : %s" 가 아니라 --pretty=format:%h - %an, %ar : %s 가 저장되어

있습니다. 즉, doble quotation이 빠져서 저장되네요...

방법이 없는 걸까요?

jick의 이미지

Double quotation을 다시 single quote로 싸주시면 됩니다.

mygit log --pretty=format:'"%h - %an, %ar : %s"'
 
혹은 다음과 같이 써도 마찬가지:
mygit log '--pretty=format:"%h - %an, %ar : %s"'
sunnyncom의 이미지

스크립트 내에서 처리할 수 있는 방법은 없는지요?