rakitzis / rc

rc shell -- independent re-implementation for Unix of the Plan 9 shell (from circa 1992)
Other
250 stars 23 forks source link

`if not` affected by vacuous `if (false)` #82

Closed borkovic closed 1 year ago

borkovic commented 1 year ago

if not behaves differently when vacuous if (false) is added.

Current master commit:

$ g br
* master 8ca9ab1 [origin/master] Merge pull request #72 from rakitzis/travis

Without if (false):

$ cat F4
L=xx
if (true) {
}
if not L=($L  a3)
whatis L
$ rc F4
L=xx

With if (false)"

$ cat F5
if (false) {
}
L=xx
if (true) {
}
if not L=($L  a3)
whatis L
$ rc F5
L=(xx a3)

I discovered it when I added if (...) { ... } to my .rcrc file and found that trip.rc fails in the same manner.
I was calling rc with the -l flag.

Should if (...) be visible across files? I did not expect it to be.

borkovic commented 1 year ago

Does a if not statement have to follow an if statement immediately?

Found at this man page:

if not command The immediately preceding command must have been if(list) command. If its condition was non-zero, the command is executed.

rakitzis commented 1 year ago

Hi Drazen, I'm afraid the if not syntax was retrofitted late in rc's life by a maintainer who is no longer associated with the project. When I have the time to clean up the loose ends I would prefer to remove this syntax entirely; as far as I am concerned it was added experimentally. At the moment I have little spare time to devote to rc maintenance.

xyb3rt commented 1 year ago

I've removed the if not syntax, so this is no longer an issue.