FUNCTION CheckDir, Name, LongName, stay=stay, silent=silent @compile_opt.pro ; On error, return to caller ; On Linux if Name contains a trailing * the cd may actually succeed ; (the wildcard is apparently ignored). IF strpos(Name,'*') NE -1 THEN RETURN, 0 InitVar, stay , /key InitVar, silent , 0 cd, current=old ; First pick up the current directory. catch, Error ; Returns, 0 if next CD fails IF Error EQ 0 THEN BEGIN cd, Name ; Test for existing by changing directory CASE stay OF 0: cd, old, current=LongName; Restore current dir; pick up full path 1: cd, current=LongName ENDCASE LongName = filepath(root=LongName,'') ENDIF catch, /cancel IF Error NE 0 THEN BEGIN LongName = '' IF silent LE 0 THEN message, /info, who_am_i(/caller)+': '+hide_env(Name)+' does not exist' ENDIF RETURN, Error EQ 0 & end