/* * ----------------------------------------------------------------- * Execution of this macro requires a license for uni-XEDIT Extended * for each concurrent user of the macro. * ----------------------------------------------------------------- * * * * shellxe.xedit - macro to replace the "xedit" sub-command that * includes support for expanding shell variables * and shorthand * * To use this, you must set a synonym with * * set synonym xe shellxe * * This may be added to your .profile.xedit if you wish to use * this replacement at all times. * * Shellxe.xedit calls three other external Rexx programs: * "expand", "justone", and "expmsg". These routines as well as * "shellxe.xedit" must be in a directory that is specified * in the XEDITPATH environment variable. * * Modification History: * * 04 Aug 94 twg Initial implementation * */ parse arg inparms /* get calling arguments */ file_list = '' /* default for list of files is null */ expanded_list = '' /* same for list of filename expansions */ xe_options = '' /* initialize invocation options */ profile = '' /* initialize profile name */ msg = '' /* initialize error message string */ prof_ok = 1 /* flag to indicate valid profile name */ z = inparms do while z \= '' /* go through input args, building up command args */ parse var z next z /* get next token */ if left(next, 1) = '-' then do /* starts with "-" so it's an option */ if upper(left(next, 2)) = '-P' then do /* if it's "-p"? */ parse var z profile z /* next token should be prof name */ if profile = '' | left(profile, 1) = '-' then do /* if no prof name */ msg = 'Profile name not specified' /* set appropriate message */ prof_ok = 0 end else do /* if we think we got a valid profile name */ profname = expand(profile) /* expand profile name */ if \justone(profname) then prof_ok = 0 /* got a bad expansion */ end if \prof_ok then do /* if profile name invalid for some reason */ call expmsg 'shellxe', msg /* just halt everything right here */ 'cmsg xe' inparms exit end next = next profname /* concatenate the '-p' and the profile name */ end /* end of "if we got a -p" loop */ /* certain invocation options are not valid with the subcommand */ if upper(left(next, 4)) = '-NOK' | upper(left(next, 2)) = '-L' |, upper(left(next, 2)) = '-H' | next == '-' then next = '' xe_options = xe_options next /* append this option to options string */ end /* end of "if we got a token beginning with '-' " loop */ else file_list = file_list next /* otherwise, it's a file name */ end /* end of "do while inparms" loop */ if file_list \= '' then do /* if we have some filenames, expand them */ expanded_list = expand(file_list) if words(expanded_list) = 0 then do /* if names couldn't be resolved */ msg = 'File names could not be expanded or resolved' /* just halt here */ call expmsg 'shellxe', msg 'cmsg xe' inparms exit end end do while expanded_list \= '' /* process every filename in the expansion list */ parse var expanded_list next expanded_list 'command xedit' next xe_options end if inparms = '' then 'command xedit' /* just move to next in ring if no args */