T.R | Title | User | Personal Name | Date | Lines |
---|
8675.1 | | VAXCPU::michaud | Jeff Michaud - ObjectBroker | Fri Jan 31 1997 19:26 | 14 |
| > The ASCII equivalent to the CR is ^M but this doesn't work in
> a comparison statement i.e
>
> if [[ $answer = "^M" ]]; then
Sounds like you want to determine if the user simply pressed
return w/out entering anything. The way to test for that is
to get for the empty string, ie:
if [[ $answer = "" ]]; then
because unless you've told the terminal driver to not map carriage
returns to newlines, you'll never see a carriage return unless the
user escaped it (ie. ^V^M) and then hit return.
|
8675.2 | NOTES collision - but be sure to quote $answer | CFSCTC::SMITH | Tom Smith MRO1-3/D12 dtn 297-4751 | Fri Jan 31 1997 19:30 | 15 |
| If you're doing something like testing for a null response (<CR> only)
to a "read", you can use something like the following:
read answer
if [ -z "$answer" ]
then
answer="default answer"
fi
This is also Bourne shell-compatible. The string-compare version of the
test would be `[ "$answer" = "" ]'. The double brackets can be used but
are only necessary for ksh-specific tests. See test(1) for the "plain
vanilla" versions.
-Tom
|
8675.3 | Works great | STOSS1::HORVATH | | Mon Feb 03 1997 11:16 | 2 |
| Thanks menu script works fine.
|