-
Notifications
You must be signed in to change notification settings - Fork 41
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
Introduce 'function' built-in. #77
Open
Krush206
wants to merge
27
commits into
tcsh-org:master
Choose a base branch
from
Krush206:function
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Commits on Jun 1, 2024
-
As requested in tcsh-org#4, here's my proposal. This is a wrapper around goto and source. The script recurses itself and searches for a goto label. It's an error for labels not contain an exit to their end. Function calls outside labels are, by default, labeled main. This was tested sparsely, and may contain bugs I haven't faced, but is working as expected. One bug to be noted is that pipes don't give up on errors. This is possibly due to forking. I noticed Tcsh has a built-in function command, but I can't trace the code. Said built-in function command is evaluated before mine, thus those who attempt to execute it won't get the correct error message.
Configuration menu - View commit details
-
Copy full SHA for faab6cc - Browse repository at this point
Copy the full SHA faab6ccView commit details -
Configuration menu - View commit details
-
Copy full SHA for b683769 - Browse repository at this point
Copy the full SHA b683769View commit details -
Configuration menu - View commit details
-
Copy full SHA for 4d90ff3 - Browse repository at this point
Copy the full SHA 4d90ff3View commit details -
Configuration menu - View commit details
-
Copy full SHA for 715a882 - Browse repository at this point
Copy the full SHA 715a882View commit details -
Configuration menu - View commit details
-
Copy full SHA for 5e37bfc - Browse repository at this point
Copy the full SHA 5e37bfcView commit details -
Configuration menu - View commit details
-
Copy full SHA for 235b358 - Browse repository at this point
Copy the full SHA 235b358View commit details -
Configuration menu - View commit details
-
Copy full SHA for 4a54e05 - Browse repository at this point
Copy the full SHA 4a54e05View commit details -
Configuration menu - View commit details
-
Copy full SHA for 5bc9252 - Browse repository at this point
Copy the full SHA 5bc9252View commit details -
Configuration menu - View commit details
-
Copy full SHA for b1e4135 - Browse repository at this point
Copy the full SHA b1e4135View commit details -
Configuration menu - View commit details
-
Copy full SHA for ede350d - Browse repository at this point
Copy the full SHA ede350dView commit details -
Configuration menu - View commit details
-
Copy full SHA for fc7dbd3 - Browse repository at this point
Copy the full SHA fc7dbd3View commit details -
Configuration menu - View commit details
-
Copy full SHA for d762fba - Browse repository at this point
Copy the full SHA d762fbaView commit details -
Configuration menu - View commit details
-
Copy full SHA for 951264d - Browse repository at this point
Copy the full SHA 951264dView commit details -
Configuration menu - View commit details
-
Copy full SHA for 7d6eef8 - Browse repository at this point
Copy the full SHA 7d6eef8View commit details -
Functions should work for sourced scripts.
Next, make a table of functions so they can be called globally. Currently, it isn't possible to call functions from sourced files other than the current.
Configuration menu - View commit details
-
Copy full SHA for c60a4c2 - Browse repository at this point
Copy the full SHA c60a4c2View commit details
Commits on Jun 3, 2024
-
I think functions based on pipes makes a simpler feature, as well as allows for use in interactive sessions, resembling Bourne-compatible Shells better. Unlike the goto-based version, functions may only be called if they were previously declared (i.e: no forward jumps), making a similar behavior to Bourne-compatible Shells. This version relies on a tree derived from variables and aliases. Unlike to aliases and variables, the tree is restrictive. Once a function is declared, may not be redeclared or undeclared. I was afraid this wouldn't work out for some operations, such as loops and gotos, because pipes cannot rewind. Fortunately, I was wrong, and the fact these operations are possible from interactive sessions, from a terminal, makes the assumption just as wrong, though I'm clueless as to how rewinding is possible on unsupported sources.
Configuration menu - View commit details
-
Copy full SHA for 954cfd6 - Browse repository at this point
Copy the full SHA 954cfd6View commit details -
Though POSIX defines a minimum for pipe buffer, I decided is safer writing one byte a time. This may render slow reads, though writing in larger quantities rendered broken reads. For an unknown reason, some operations, after SIGINT, rendered exiting the Shell. This happens on the ERR_RECURSION error as well. longjmp remedies the issue, though I'm afraid isn't the best solution.
Configuration menu - View commit details
-
Copy full SHA for 15d4e30 - Browse repository at this point
Copy the full SHA 15d4e30View commit details -
Configuration menu - View commit details
-
Copy full SHA for 042e84b - Browse repository at this point
Copy the full SHA 042e84bView commit details -
Configuration menu - View commit details
-
Copy full SHA for 2fa7967 - Browse repository at this point
Copy the full SHA 2fa7967View commit details -
Configuration menu - View commit details
-
Copy full SHA for b950b85 - Browse repository at this point
Copy the full SHA b950b85View commit details -
Configuration menu - View commit details
-
Copy full SHA for d840e89 - Browse repository at this point
Copy the full SHA d840e89View commit details
Commits on Jun 4, 2024
-
Configuration menu - View commit details
-
Copy full SHA for 22d3150 - Browse repository at this point
Copy the full SHA 22d3150View commit details -
Configuration menu - View commit details
-
Copy full SHA for adea1b6 - Browse repository at this point
Copy the full SHA adea1b6View commit details -
Configuration menu - View commit details
-
Copy full SHA for d0167d4 - Browse repository at this point
Copy the full SHA d0167d4View commit details
Commits on Jun 6, 2024
-
Configuration menu - View commit details
-
Copy full SHA for 911ed6e - Browse repository at this point
Copy the full SHA 911ed6eView commit details
Commits on Jun 7, 2024
-
Configuration menu - View commit details
-
Copy full SHA for 56e5e7d - Browse repository at this point
Copy the full SHA 56e5e7dView commit details
Commits on Jun 13, 2024
-
Configuration menu - View commit details
-
Copy full SHA for c8b8f51 - Browse repository at this point
Copy the full SHA c8b8f51View commit details
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.