는 bash 쉘에서 나는 스크립트 소스, 링크에 의해 호출 된 경우에도 스크립트의 전체 경로를 얻을 수 있습니다/... 등 이 마법의 bash 라인 :.tcsh의 스크립트의 전체 경로
#Next lines just find the path of the file.
#Works for all scenarios including:
#when called via multiple soft links.
#when script called by command "source" aka . (dot) operator.
#when arg $0 is modified from caller.
#"./script" "/full/path/to/script" "/some/path/../../another/path/script" "./some/folder/script"
#SCRIPT_PATH is given in full path, no matter how it is called.
#Just make sure you locate this at start of the script.
SCRIPT_PATH="${BASH_SOURCE[0]}";
if [ -h "${SCRIPT_PATH}" ]; then
while [ -h "${SCRIPT_PATH}" ]; do SCRIPT_PATH=`readlink "${SCRIPT_PATH}"`; done
fi
pushd `dirname ${SCRIPT_PATH}` > /dev/null
SCRIPT_PATH=`pwd`;
popd > /dev/null
TCSH 셸에서과 동일한 조건으로 스크립트 경로 을 어떻게 얻을 수 있습니까? 이 '마술 라인'은 무엇입니까?
P. this 및 이와 유사한 질문이 중복되어 있지 않습니다. 나는 $0
을 알고 있습니다.
[tcsh에서 스크립팅을 피할 수 있다면 가능합니다.] (http://www.grymoire.com/Unix/CshTop10.txt) – Johnsyweb
나는 당신에게 절대 동의합니다. 하지만 내 목표는 사용자 생활을 가능한 한 쉽게 만드는 것입니다. 그리고 그들이 어디서든 "source environment.csh"를 실행할 수 있다면 쉽게 할 수 있습니다. TCSH 요구 사항은 RHEL 6이이를 사용자의 기본 쉘로 사용하기 때문입니다. – MajesticRa
tsch가 기본 쉘이기 때문에 tsch를 사용하는 경우 기본 쉘을 변경하지 않으시겠습니까? – carlpett