I want to make a proc that does
run first
echo enough
read nuff
if nuff then exit
else second
exhout enough
read nuff
if nuff then exit
else third
I'm unclear about the if/exit syntax
In <son1pb$qe5$1@dont-email.me> by Janis Papanagnou <janis_papanagnou@hotmail.com> on Tue, 07 Dec 2021 02:16:59 we perused:
*+-On 07.12.2021 07:27, vjp2.at@at.BioStrategist.dot.dot.com wrote:
I'm unclear about the if/exit syntax
*+-finally you may (or may not) want to provide an exit code to 'exit' *+-('exit 0' if successful, 'exit 1' to return an error indication.
Thanks much! The numbers after the exit confused me
Basically I want to run the same search through three search engines
(brave, qwant, dogpile) but if I'm happy witht he first round,
stop searching.
I want to make a proc that does
run first
echo enough
read nuff
if nuff then exit
else second
exhout enough
read nuff
if nuff then exit
else third
I'm unclear about the if/exit syntax
Not really, but I think the second if should be an elif
and exit lands me back in my interrupted login script
which makes me wonder if it might not also log me off.
I changed the -n to -z because "no" exited
exit does indeed log me out
Thanks, I got it, worked on first try!! :
wearch () {
SRCH=`echo $* | sed -e 's/ /+/g'`;
lynx -accept_all_cookies -useragent 'Mozilla/5.0 (Windows NT 6.1; rv:60.0) Gecko/20100101 Firefox/60.0' 'https://search.brave.com/search?q='$SRCH ;
echo "return if enough else qwant";
read nuff;
if [[ -n "$nuff" ]]
then exit
else lynx -accept_all_cookies -useragent 'Mozilla/5.0 (Windows NT 6.1; rv:60.0) Gecko/20100101 Firefox/60.0' 'https://www.qwant.com/?q='$SRCH ;
fi;
echo "return if enough else dogpile";
read nuff;
if [[ -n "$nuff" ]]
then exit
else lynx -accept_all_cookies -useragent 'Mozilla/5.0 (Windows NT 6.1; rv:60.0) Gecko/20100101 Firefox/60.0' 'http://www.dogpile.com/search/web?q='$SRCH ;
fi;
}
On 08.12.2021 07:02, vjp2.at@at.BioStrategist.dot.dot.com wrote:
wearch () {
SRCH=`echo $* | sed -e 's/ /+/g'`;
Based on the code above and some comments dispersed in the thread
you may want to have a look at the subsequent code with changes
* substitution is done by shell (without sed)
wearch()
{
ARGS=$*
SRCH=${ARGS// /+}
Janis Papanagnou wrote:
On 08.12.2021 07:02, vjp2.at@at.BioStrategist.dot.dot.com wrote:
wearch () {
SRCH=`echo $* | sed -e 's/ /+/g'`;
Based on the code above and some comments dispersed in the thread
you may want to have a look at the subsequent code with changes
* substitution is done by shell (without sed)
wearch()
{
ARGS=$*
SRCH=${ARGS// /+}
This change introduces a dependency on the value of IFS. It will
only work correctly if IFS is not empty and the first character is a
space (which it is by default, but IFS could be changed by code that
calls the wearch function).
My inclination would be to use a loop to build the SRCH value:
SRCH=""
for ARG
do
SRCH="$SRCH${SRCH:++}$ARG"
done
This, together with changing [[ "$yn" != "y" ]] to [ "$yn" != "y" ],
would make the function work with any POSIX shell.
(But I am puzzled at the moment why
ARGS=$@
SRCH=${ARGS// */+}
doesn't work. Guess I need some coffee.)
On 10.12.2021 14:41, Geoff Clare wrote:
Janis Papanagnou wrote:
On 08.12.2021 07:02, vjp2.at@at.BioStrategist.dot.dot.com wrote:
wearch () {
SRCH=`echo $* | sed -e 's/ /+/g'`;
Based on the code above and some comments dispersed in the thread
you may want to have a look at the subsequent code with changes
* substitution is done by shell (without sed)
wearch()
{
ARGS=$*
SRCH=${ARGS// /+}
This change introduces a dependency on the value of IFS. It will
only work correctly if IFS is not empty and the first character is a
space (which it is by default, but IFS could be changed by code that
calls the wearch function).
Interesting.
This simple change seems to work, though, with IFS=''
ARGS=$@
SRCH=${ARGS// /+}
(or please correct me if I am wrong).
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 285 |
Nodes: | 16 (2 / 14) |
Uptime: | 72:17:59 |
Calls: | 6,489 |
Calls today: | 2 |
Files: | 12,096 |
Messages: | 5,275,731 |