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

new function: type #609

Closed
lmorg opened this issue Jun 4, 2023 · 1 comment · Fixed by #673
Closed

new function: type #609

lmorg opened this issue Jun 4, 2023 · 1 comment · Fixed by #673
Labels
deployed to `develop` Feature built. Currently BETA testing in the `develop` branch enhancement New features in progress Issue is currently being worked on (possibly in a feature branch)

Comments

@lmorg
Copy link
Owner

lmorg commented Jun 4, 2023

Describe the problem:
Bash et al have a builtin named type:

type [-afptP] [name …]

For each name, indicate how it would be interpreted if used as a command name.

If the -t option is used, type prints a single word which is one of ‘alias’, ‘function’, ‘builtin’, ‘file’ or ‘keyword’, if name is an alias, shell function, shell builtin, disk file, or shell reserved word, respectively. If the name is not found, then nothing is printed, and type returns a failure status.

If the -p option is used, type either returns the name of the disk file that would be executed, or nothing if -t would not return ‘file’.

The -P option forces a path search for each name, even if -t would not return ‘file’.

If a command is hashed, -p and -P print the hashed value, which is not necessarily the file that appears first in $PATH.

If the -a option is used, type returns all of the places that contain an executable named file. This includes aliases and functions, if and only if the -p option is not also used.

If the -f option is used, type does not attempt to find shell functions, as with the command builtin.

The return status is zero if all of the names are found, non-zero if any are not found.

source: https://www.gnu.org/software/bash/manual/html_node/Bash-Builtins.html
examples: https://linuxize.com/post/linux-type-command/

Possible ways to implement:
This will likely need to be a new builtin rather than a Murex function

Additional context:
This adds better compatibility with existing POSIX / GNU / BSD shells but also provides a more convenient solution to checking runtime (https://murex.rocks/docs/commands/runtime.html)

@lmorg lmorg added the enhancement New features label Jun 4, 2023
@lmorg
Copy link
Owner Author

lmorg commented Aug 20, 2023

Should also add which too

lmorg added a commit that referenced this issue Aug 21, 2023
lmorg added a commit that referenced this issue Aug 23, 2023
@lmorg lmorg added the in progress Issue is currently being worked on (possibly in a feature branch) label Aug 26, 2023
@lmorg lmorg linked a pull request Aug 26, 2023 that will close this issue
@lmorg lmorg mentioned this issue Aug 27, 2023
@lmorg lmorg added the deployed to `develop` Feature built. Currently BETA testing in the `develop` branch label Sep 6, 2023
lmorg added a commit that referenced this issue Sep 6, 2023
@lmorg lmorg closed this as completed in #673 Sep 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deployed to `develop` Feature built. Currently BETA testing in the `develop` branch enhancement New features in progress Issue is currently being worked on (possibly in a feature branch)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant