<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<html><head><meta http-equiv="Content-Type" content="text/html; CHARSET=UTF-8" /><meta name="GENERATOR" content="GtkHTML/3.32.2" /></head><body>Ah. Yeah. Getting the | to be read and not executed and then executed and not read will fail. <br>
<br>
Chunk it into an array and search without the case. <br>
<br>
Or grep.<br><br><div class="gmail_quote">On August 3, 2015 1:53:52 PM EDT, Neal Rhodes <neal@mnopltd.com> wrote:<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Perhaps I didn't make it clear enough. Yes, the first approach of hard coding case values works. <br />
<br />
All the other approaches of trying to put the values in a variable do not work. <br />
<br />
<br />
On Mon, 2015-08-03 at 12:33 -0400, Jim Kinney wrote:
<blockquote type="CITE">
This works:
</blockquote>
<blockquote type="CITE">
<br />
<br />
</blockquote>
<blockquote type="CITE">
#!/bin/bash
</blockquote>
<blockquote type="CITE">
<br />
<br />
</blockquote>
<blockquote type="CITE">
FRED='one'
</blockquote>
<blockquote type="CITE">
<br />
<br />
</blockquote>
<blockquote type="CITE">
case $FRED in
</blockquote>
<blockquote type="CITE">
one|two|pie) echo "got ${FRED}"; ;;
</blockquote>
<blockquote type="CITE">
*) echo "crud"; ;;
</blockquote>
<blockquote type="CITE">
esac
</blockquote>
<blockquote type="CITE">
<br />
<br />
</blockquote>
<blockquote type="CITE">
<br />
<br />
</blockquote>
<blockquote type="CITE">
<br />
<br />
</blockquote>
<blockquote type="CITE">
On Mon, 2015-08-03 at 12:03 -0400, Neal Rhodes wrote:
</blockquote>
<blockquote type="CITE">
<blockquote type="CITE">
Exactly how does not assign a list of values separated by pipe to use that variable later on in a script and make a CASE statement happy? <br />
The script below shows a variety of attempts. <br />
<br />
Ultimately, we're aiming to grab the list from a file, eg "LIST="`cat allow.list`"<br />
<br />
<br />
<blockquote>
REMOTE_ADDR=one<br />
<br />
case $REMOTE_ADDR in<br />
one|two|three) echo "I like $REMOTE_ADDR" ;; # Picks this one.<br />
*) echo "I do NOT like $REMOTE_ADDR" ;;<br />
esac<br />
<br />
LIST="one|two|three"<br />
case $REMOTE_ADDR in<br />
$LIST) echo "But now I like $REMOTE_ADDR" ;;<br />
*) echo "But now I do NOT like $REMOTE_ADDR" ;; # Picks this one.<br />
esac<br />
<br />
case $REMOTE_ADDR in<br />
"$LIST") echo "And I like $REMOTE_ADDR" ;;<br />
*) echo "And I do NOT like $REMOTE_ADDR" ;; # Picks this one.<br />
esac<br />
<br />
LIST="one"<br />
case $REMOTE_ADDR in<br />
"$LIST") echo "Yet I like $REMOTE_ADDR" ;; # Picks this one.<br />
*) echo "Yet I do NOT like $REMOTE_ADDR" ;;<br />
esac<br />
<br />
LIST="one\|two\|three"<br />
case $REMOTE_ADDR in<br />
$LIST) echo "However now I like $REMOTE_ADDR" ;;<br />
*) echo "However now I do NOT like $REMOTE_ADDR" ;; # Picks this one.<br />
esac<br />
</blockquote>
<br />
<pre>
_______________________________________________
Ale mailing list
<a href="mailto:Ale@ale.org">Ale@ale.org</a>
<a href="http://mail.ale.org/mailman/listinfo/ale">http://mail.ale.org/mailman/listinfo/ale</a>
See JOBS, ANNOUNCE and SCHOOLS lists at
<a href="http://mail.ale.org/mailman/listinfo">http://mail.ale.org/mailman/listinfo</a>
</pre>
</blockquote>
</blockquote>
<blockquote type="CITE">
<pre>
--
James P. Kinney III
Every time you stop a school, you will have to build a jail. What you
gain at one end you lose at the other. It's like feeding a dog on his
own tail. It won't fatten the dog.
- Speech 11/23/1900 Mark Twain
http://heretothereideas.blogspot.com/
</pre>
</blockquote>
<blockquote type="CITE">
<pre>
_______________________________________________
Ale mailing list
<a href="mailto:Ale@ale.org">Ale@ale.org</a>
<a href="http://mail.ale.org/mailman/listinfo/ale">http://mail.ale.org/mailman/listinfo/ale</a>
See JOBS, ANNOUNCE and SCHOOLS lists at
<a href="http://mail.ale.org/mailman/listinfo">http://mail.ale.org/mailman/listinfo</a>
</pre>
</blockquote>
<br />
<p style="margin-top: 2.5em; margin-bottom: 1em; border-bottom: 1px solid #000"></p><pre class="k9mail"><hr /><br />Ale mailing list<br />Ale@ale.org<br /><a href="http://mail.ale.org/mailman/listinfo/ale">http://mail.ale.org/mailman/listinfo/ale</a><br />See JOBS, ANNOUNCE and SCHOOLS lists at<br /><a href="http://mail.ale.org/mailman/listinfo">http://mail.ale.org/mailman/listinfo</a><br /></pre></blockquote></div><br>
-- <br>
Sent from my Android device with K-9 Mail. Please excuse my brevity.</body></html>