root@lingua.cltr.uq.OZ.AU (Hulk Hogan) (05/10/91)
Hi,
I have a fun menu-based shell for my naive users written in
shell script. I have a problem, in that I have to send in a ? character
to a routine, but am having problems.
Some background. I have a function "do_menu" displays a menu, gets a choice
and then runs that choice. It takes the items on the menu, and the programs
to run as arguments. Some of these programs have arguments, so that I use
double quotes to keep them together.
One of these commands sends in a "?" character as the argument. (It is
called by other menu selections with other characters as argument.)
An equivalent function to demonstrate my problem would be
% sh
$ dm()
{
$*
}
To demonstrate, I use the simple example of dm "echo ?", which just
runs "echo ?". However, I want to get a ? character printed out.
Not the results of explanding the meta-character ?, or the string '?' or
\? or whatever. Just the single character ?. Any ideas?
Here's what I've tried.
$ ls ?
1 4
$ dm "echo ?"
1 4
$ dm 'echo ?'
1 4
$ dm "echo \?"
\?
$ dm 'echo \?'
\?
$ dm "echo '?'"
'?'
$ dm 'echo "?"'
"?"
$
If it's any help, I'm on a SPARC running SunOS 4.0.3. Is this yet another
fixed-in-4.1 sun bug???
/\ndy
--
Andrew M. Jones, Systems Programmer, Internet: andy@lingua.cltr.uq.oz.au
Centre for Lang. Teaching & Research, UUCP: uunet!lingua.cltr.uq.oz.au!andy
University of Queensland, St. Lucia, Phone: +61 7 365 6915 (Use 07 in Oz)
Brisbane, Qld. AUSTRALIA 4072 Fax: +61 7 365 7077 IRC: HulkHogan
"No matter what hits the fan, it's never distributed evenly....."
rhartman@thestepchild.sgi.com (Robert Hartman) (05/11/91)
In article <1141@cracklin.oat.bran.gnu.ai.mit.edu> pfalstad@phoenix.princeton.edu (Paul Falstad) writes: >root@lingua.cltr.uq.OZ.AU (Hulk Hogan) wrote: >>% sh >>$ dm() >>{ >>$* >>} > >dm() >{ >"$@" >} > >>$ ls ? >>1 4 >>$ dm "echo ?" >>1 4 > >$ dm "echo ?" >? >$ ... In sh, if filename expansion fails, the pattern is taken as a literal, so in Paul's example (the second above), there must not have been any 1-character filenames in the working directory. I'm not sure how to turn of globbing (filename expansion) in the Bourne shell, but that's what needs to be done for this to work reliably. Anybody recall how to do that? -r