Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Executing flag n + in a script does not stop execution. #93

Open
borkovic opened this issue Jan 17, 2024 · 2 comments
Open

Executing flag n + in a script does not stop execution. #93

borkovic opened this issue Jan 17, 2024 · 2 comments

Comments

@borkovic
Copy link
Contributor

rc/ $ cat s
ls trip*

flag n +
ls sig*.c

flag n -
ls glo*.c

Executing flag n + does not stop execution. If it did, how would we recover flag n -. Should flag 'n' be immutable?

rc/ $ rc -x s
ls trip.rc tripping.c
trip.rc		tripping.c
flag n +
ls sigmsgs.c signal.c
sigmsgs.c	signal.c
flag n -
ls glob.c glom.c
glob.c	glom.c

I expected no output, similar to the case when -n is passed on the command line:

rc/ $ rc -n -c 'ls trip*'
rc/ $
rc/ $ rc -x -n -c 'ls trip*'
ls trip*
@rakitzis
Copy link
Owner

Right, this is alluded to in the commit which added "flag". I have to say this is an unfortunate tangle at this point. I added -n mostly for testing purposes back in the day. "flag" was added much later. Perhaps it should simply reject "n" with an error. Resuming execution with "flag n -" makes no sense.

@borkovic
Copy link
Contributor Author

Bash man page says set -n is ignored in interactive shells:

-n      Read commands but do not execute them.  This may be used to check a shell script for syntax errors.  This is ignored by interactive shells.

I agree with

Perhaps it should simply reject "n" with an error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants