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

Feature Request: Partial runtime validator backed by Morbig for POSIX shell #3008

Open
anadon opened this issue Jun 27, 2024 · 0 comments
Open

Comments

@anadon
Copy link

anadon commented Jun 27, 2024

I have implemented a very in development tool for use with POSIX shells which does two things currently. Firstly, it rigorously validates the syntax of the script. Secondly, it reports back on stdout in a space-delimited fashion the programs used but which could not be found on any value found in $PATH. On error, a non-zero exit code is set with an error message, usually the like and column of a syntax error of the user's script where the error occurred.

This is great and all. But would this be of help to users of shellcheck to have some header like the following?

#! /usr/bin/env sh

if ! command -v detect_programs_called_from_script > /dev/null 2> /dev/null
then
    missing_programs=detect_programs_called_from_script  < "$(pwd)"'/'"$0" 
    if [ $? != 0 ] ; then
        echo "Script self-terminating early; detected syntax error"
        echo $missing_programs
        exit 1
    fi
    if [ $missing_programs != "" ] ; then
        echo "Script calls programs which could not be resolved."
        echo "These programs are: $missing_programs"
        exit 1
    fi
fi

For many installers like Nvidia's or Guix's, this would be very helpful. But the use case may be too niche to bother with. There could also be outright technically superior alternatives which should be used instead. I don't know. I'm looking for some feedback.

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

1 participant