Thanks Charles,

I  jumped to using Your U routine and came up with two enhancements.

1) Print a warning when the command supplied uses all three of \,' and " .
    Can anyone dream up a way of handling it instead ?

2)  Add some hardcoded command aliases
  ( It's sooo irritating to shell out from uv to find that your
    unix aliases don't work ! )

and in the spirit of open source  the enhanced program is here:

--------------------------------------------

CMD = TRIMF( @SENTENCE )[' ',2,999] IF CMD = OCONV( CMD,'MCU') THEN CMD = OCONV( CMD,'MCL' ) UC = CMD[' ',1,1] ** Some aliases, change and/or add Your own: BEGIN CASE CASE UC = 'll'; CMD = '/usr/ucb/ls -ls ':CMD[' ',2,999] CASE UC = 'ps'; CMD = '/usr/ucb/':CMD END CASE IF INDEX(CMD,'"',1) THEN IF INDEX(CMD,"'",1) THEN IF INDEX(CMD,'\',1) THEN CRT "Sorry, but you've used all quotes!" END ELSE CMD = '\':CMD:'\' END END ELSE CMD = SQUOTE(CMD) END END ELSE CMD = DQUOTE(CMD) END EXECUTE "sh -c ":CMD STOP END ----------------------------------------------------------------------------------------------------- (( For the curious: /usr/ucb is where the Berkely command versions are kept on solaris ))

-- mats

<<   Intentional overquoting  to faciliate comparisons.   >>



Stevenson, Charles wrote:

For working at TCL, typing SH -c and proper quote marks, too, is just
way too hard for me.
So I have a little utility verb, "U", that just takes everything after
the first word, and dispatches it.
Furthermore, if the entire line is Uppercase (the usual for TCL), then
it figures you probably meant Lowercase (the usual for Unix), so it
flips it before handing it to sh.

  U PWD; LS -L
  U ls -l \&SAVEDLISTS\& | grep "Nov  9"

get executed as

  SH -c"pwd; ls -l"
  SH -c'u ls -l \&SAVEDLISTS\& | grep "Nov  9"'

respectively.
If you insist on using all 3 (',", and \), you're on your own.

-----------------------

PROGRAM U
* Author: Charles Stevenson
* Date  : Jan. 1999
* Type  : General Utility verb
* Desc. : Shells to unix & executes what's on the command line.
*         If entire command line is uppercase, converts everything to
*         lowercase, first.
CMD = TRIMF( @SENTENCE )[' ',2,999]
IF CMD = OCONV( CMD, 'MCU' ) THEN CMD = OCONV( CMD, 'MCL' )
IF INDEX( CMD, '"', 1 ) THEN
 IF INDEX( CMD, "'", 1 ) THEN
   CMD = '\':CMD:'\'
 END ELSE
   CMD = SQUOTE( CMD )
 END
END ELSE
 CMD = DQUOTE( CMD )
END
EXECUTE 'SH -c':CMD STOP
-------
u2-users mailing list
[email protected]
To unsubscribe please visit http://listserver.u2ug.org/
-------
u2-users mailing list
[email protected]
To unsubscribe please visit http://listserver.u2ug.org/

Reply via email to