/* * ----------------------------------------------------------------- * This Rexx program is called by several of the uni-XEDIT macros in * the Sample Library. To use this program in any other context * requires a license for uni-REXX on the host computer where the * program is to be run. * ----------------------------------------------------------------- * * * * expand - program to expand environment variables and shell * shorthand * * Syntax: expand() * * is a filename or path that may or may not * include environment variables beginning with "$" or such * shorthand as "~" (C shell shorthand for $HOME) * * Returns the fully-expanded path(s) corresponding to the description * specified. * * May be invoked as a function or called as a subroutine * * Must be in a directory specified in the environment variable XEDITPATH. * * * Modification History: * * 25 Jul 94 twg Initial implementation * */ parse arg descriptor expansion = '' /* initialize expanded file list */ which_shell = getenv('SHELL') /* get shell that is to do expansion */ esc_descriptor = '' /* initialize escaped filename */ do i = 1 to length(descriptor) /* put "\" before every character of filename */ char = substr(descriptor, i, 1) /* so nothing can possibly be expanded */ esc_descriptor = esc_descriptor'\'char /* before it's piped to the shell */ end command = "echo \e\c\h\o" esc_descriptor "|" which_shell "-f 2> /dev/null" call popen command /* execute the command, results on the stack */ do queued() /* process what's on the stack */ parse pull what /* get the next item */ expansion = expansion||what /* append it to the expansion */ end return expansion /* return the expansion */