🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.unix.shell
5 messages
5 total messages Started by Ian Watson Wed, 17 Oct 1990 14:51
What's set -n for ?
#1519
Author: Ian Watson
Date: Wed, 17 Oct 1990 14:51
16 lines
978 bytes
What's the point of the -n option for the 'set' command of sh ?

	-n	Reads commands but does not execute them

If you have set it, how would you ever unset it ?

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Ian Watson, HP Pinewood Information Systems Division, England.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Phone :				(Intl)+44 344 763015
Unix mail (Internet) :		ian@hpopd.HP.COM
Unix mail (UUCP) :		...!hplabs!hpopd!ian
Openmail :			ian watson/pinewood,lab,hpopd
Openmail from Unix :		ian_watson/pinewood_lab_hpopd@hpopd
HPDesk :			Ian WATSON/HP1600
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Re: What's set -n for ?
#1541
Author: carl brandauer
Date: Fri, 19 Oct 1990 15:42
13 lines
1000 bytes
In article <23880001@hpopd.HP.COM> ian@hpopd.HP.COM (Ian Watson) writes:
>What's the point of the -n option for the 'set' command of sh ?
>
>	-n	Reads commands but does not execute them
>
>If you have set it, how would you ever unset it ?

When writing shell scripts, 'set -n' is useful for detecting syntax
errors without risking the dangers that might occur if every command were
executed.

If you set -n on the command line, logging off is the only way to unset
it.
Re: What's set -n for ?
#1544
Author: Joe Smith
Date: Fri, 19 Oct 1990 17:53
8 lines
841 bytes
Q: What is "-n" good for in /bin/sh?
A: "sh -nv shell_script_being_debugged".

-- 
Joe Smith (408)922-6220 | SMTP: jms@tardis.tymnet.com or jms@gemini.tymnet.com
BT Tymnet Tech Services | UUCP: ...!{ames,pyramid}!oliveb!tymix!tardis!jms
PO Box 49019, MS-C41    | BIX: smithjoe | 12 PDP-10s still running! "POPJ P,"
San Jose, CA 95161-9019 | humorous dislaimer: "My Amiga 3000 speaks for me."
Re: What's set -n for ?
#1580
Author: Martin Weitzel
Date: Mon, 22 Oct 1990 18:32
25 lines
1302 bytes
In article <1295@tardis.Tymnet.COM> jms@tardis.Tymnet.COM (Joe Smith) writes:
>Q: What is "-n" good for in /bin/sh?
>A: "sh -nv shell_script_being_debugged".

True answer, but there's an interesting bug, at least in some flavours
of UNIX SysV: A script containing

	....
	while read a
	do
		... something ....
	done
	....

hangs, even if you "debug" it with the -n option of the shell set. Note
further, that if you substitute an `if' for the `while' in the above
example, everything is fine.

Though I can understand that bugs like this may slip into a program
(execution of the internal command `read' is not properly inhibited)
I allways wondered about the differences depending on the if/while
context. Is there anybody out there with more insight (esp. someone 
with access to the shell sources?)
-- 
Martin Weitzel, email: martin@mwtech.UUCP, voice: 49-(0)6151-6 56 83
Re: What's set -n for ?
#1586
Author: Boyd Roberts
Date: Tue, 23 Oct 1990 05:39
14 lines
634 bytes
In article <23880001@hpopd.HP.COM> ian@hpopd.HP.COM (Ian Watson) writes:
>What's the point of the -n option for the 'set' command of sh ?
>

Try:

	sh -n script

Ok?


Boyd Roberts			boyd@necisa.ho.necisa.oz.au

``When the going gets wierd, the weird turn pro...''
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads