Skip to content

Fix two sh keywords in the csh setup scripts (fi, elseif) - #1842

Closed
tropibyte wants to merge 1 commit into
openhwfoundation:mainfrom
tropibyte:fix/csh-keywords
Closed

tropibyte wants to merge 1 commit into
openhwfoundation:mainfrom
tropibyte:fix/csh-keywords

Conversation

@tropibyte

Copy link
Copy Markdown

setup.csh closes an if with fi, and site-setup.csh uses elseif. Neither is csh, and tcsh does not accept either.

setup.csh:40 — fi should be endif

This is the damaging one. The block has an else, so after running either branch tcsh searches for endif, runs off the end of the file, and reports:

if: then/endif not found

(tcsh sh.func.c:975.) The practical effect is that setup.csh only completes when $RISCV/site-setup.csh is absent — when it is present, the source succeeds and then setup fails at the very last line.

site-setup.csh:57 — elseif should be else if

Quieter, but not harmless. tcsh parses elseif ( ... ) as a command with a parenthesised argument and answers

Badly placed ()'s.

with no line number, which is why it is easy to miss. The gcc-10 fallback branch is never taken, so on Ubuntu 20.04 the older toolchain is not placed on PATH.

The change

Two tokens:

-fi
+endif
-elseif ( -e $RISCV/gcc-10 ) then
+else if ( -e $RISCV/gcc-10 ) then

How this was found

Parsing a 1,287-script corpus of real-world csh/tcsh from 184 repositories with cshw, a csh implementation for Windows. Both files were verified to parse cleanly after the change.

Happy to split this into two PRs if you would rather take them separately.

🤖 Generated with Claude Code

setup.csh closes an `if' with `fi', and site-setup.csh uses `elseif'.
Neither is csh, and tcsh does not accept them.

setup.csh is the damaging one. The block has an `else', so after running
either branch tcsh searches for `endif', runs off the end of the file, and
reports "if: then/endif not found" (tcsh sh.func.c:975). The script
therefore only completes when $RISCV/site-setup.csh is ABSENT -- when it is
present, sourcing succeeds and then setup fails at the last line.

site-setup.csh is quieter but not harmless: tcsh parses `elseif ( ... )' as
a command with a parenthesised argument and answers

    Badly placed ()'s.

with no line number. The gcc-10 fallback branch is never taken, so on Ubuntu
20.04 the older toolchain is not put on PATH.

Both are one-token fixes: `fi' -> `endif', `elseif' -> `else if'.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@davidharrishmc

davidharrishmc commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

Thank you for this improvement.
You'll need to sign the eclipse ECA to make a open-source contribution.

Create an account with https://www.eclipse.org/
Sign the agreement, https://www.eclipse.org/legal/ECA.php

@davidharrishmc

Copy link
Copy Markdown
Contributor

Do you still want to proceed with this PR?

@davidharrishmc

Copy link
Copy Markdown
Contributor

Thank you @tropibyte for finding and fixing these. We can't merge this PR because the Eclipse Contributor Agreement check hasn't passed for its author, so I've re-applied the same change in #1940, which credits you and this PR as the source. Closing in favor of #1940.

rosethompson pushed a commit that referenced this pull request Oct 6, 2026
setup.csh closed an if/else with 'fi', so tcsh searched for endif, ran off
the end of the file and failed with 'if: then/endif not found' whenever
$RISCV/site-setup.csh exists.  site-setup.csh used 'elseif', which tcsh
rejects with 'Badly placed ()'s.', so the gcc-10 fallback was never taken.

Reported and first fixed by @tropibyte in #1842; this is an
independent copy of that two-token change because that PR cannot be merged
without an Eclipse Contributor Agreement.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: David Harris <David_Harris@hmc.edu>
@tropibyte

tropibyte commented Oct 6, 2026 via email

Copy link
Copy Markdown
Author

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

Successfully merging this pull request may close these issues.

2 participants