Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!uunet!mcsun!hp4nl!star.cs.vu.nl!maart From: maart@cs.vu.nl (Maarten Litmaath) Newsgroups: comp.unix.questions Subject: Re: csh question -- aliasing, quoting and the like Keywords: csh alias quotes Message-ID: <3303@solo9.cs.vu.nl> Date: 20 Sep 89 03:41:03 GMT References: <498@westc.UUCP> Organization: V.U. Informatica, Amsterdam, the Netherlands Lines: 48 gjoost@westc.UUCP (Gertjan van Oosten) writes: \... \% alias killroy 'kill `ps ax | grep -w roy | grep -v grep | awk '{print $1}'`' The `string' is broken into words as follows: 'kill `ps ax | grep -w roy | grep -v grep | awk '{print $1}'`' i.e. parts of the string aren't quoted. Solution: 'kill ... awk '\''{print $1}'\''`' ^ ^ ^ ^ ^ ^ +-------------+ +----------+ +-+ \... \% alias killroy 'rsh host kill `ps ax | grep -w roy | grep -v grep | \ awk '{print $1}'`' This would become: alias killroy \ 'rsh host kill '\''`ps ... awk '\'\\\'\''{print $1}'\'\\\'\''`'\' Er, say that again? Of course this isn't the optimal solution, regarding the number of quotes and backslashes; it is, however, a GENERAL solution. The following trick might be helpful: set q = \' set b = \\ set q1 = $b$q set b1 = $b$b set q2 = $b1$q1 # etc. alias killroy \ 'rsh host kill '$q'`ps ... awk '$q$q1$q'{print $1}'$q$q1$q'`'$q ^ ^ ^ ^ ^ ^ +---------------+ +-------------+ +----+ i.e. $q is a real quote, $q1 will be a real quote one interpretation level deeper and so on. -- creat(2) shouldn't have been create(2): |Maarten Litmaath @ VU Amsterdam: it shouldn't have existed at all. |maart@cs.vu.nl, mcvax!botter!maart