스크립트 A는 B 스크립트의 모든 변수를 가져옵니다. 문제는 스크립트 B입니다. 필요한 경우 변수가 존재하는지 또는 비어 있는지 알 수 없습니다. 사례 B에 변수가 존재하지 않는다면, 스크립트 A에서 변수를 사용합니다. A에 존재하는 경우, 변수 B를 사용합니다. 또는 그것은 존재와 B는 B.변수 (일반적으로 텍스트)가 있는지 확인하는 방법 변수가 비어있는 경우 변수가 정의되어 있지 않거나 비어 있습니다.
예에서 기본 변수에 사용할 : 내 스크립트 "B"에서 변수을 댓글이 비어있는이 경우 ...
스크립트 B.sh
#!/bin/sh
Name='<b>Variety</b>'
Comment='<span size="xx-large">Variety changes the wallpaper on a regular interval</span>'
Comment3=''
License='GPLv3'
Screenshot='http://peterlevi.com/variety/wp-content/uploads/2012/10/01-all-1024x576.jpg'
Url='http://peterlevi.com/variety/'
export Comment
export Name
export Comment3
export License
export Screenshot
export Url
스크립트 A.sh
#!/bin/sh
. $HOME/B.sh
Comment2='Variety changes the desktop wallpaper on a regular basis, using user-specified or automatically downloaded images.'
echo $display_variable_comment3_or_comment2 (depending the case)
죄송합니다. 내 영어가 잘못되었습니다 :/
우수! 감사! 멋지다! 스크립트 "A.sh"에서 변수 'Comment3'을 'Comment2'로 변경했습니다. 또한 내 스크립트 'A.sh'에서 pvar라는 새로운 변수를 만들었습니다. pvar = "$ {Comment2 : - $ Comment3}" – davidva