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

bash coproc #3126

Open
megaannum opened this issue Jan 18, 2025 · 7 comments
Open

bash coproc #3126

megaannum opened this issue Jan 18, 2025 · 7 comments

Comments

@megaannum
Copy link

megaannum commented Jan 18, 2025

ShellCheck version 0.10.0
uname -a
Linux olympia 6.11.11-300.fc41.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 18:38:25 UTC 2024 x86_64 GNU/Linux

When I enter this on the shellcheck website I get no errors:

#!/bin/bash
  
if [[ ! -v $LOAD_ONCE ]]; then
  declare -r LOAD_ONCE=1

  function do_coproc() {
    # shellcheck disable=SC2034
    local -r fn="$1"
    # shellcheck disable=SC2034
    local -ra args=( "${@:2}" )

    # shellcheck disable=SC2034
    local NAME="CP_${FUNCNAME[1]}"
    # shellcheck disable=SC1083
    coproc $NAME { LOG.redefine_jmps_child; $fn "${args[@]}"; }
    # eval 'coproc $NAME { LOG.redefine_jmps_child; $fn "${args[@]}"; }'
  }

fi

but when it is a file Test.sh and I run: shellcheck Test.sh I get:

$ shellcheck  Test.sh

In Test.sh line 3:
if [[ ! -v $LOAD_ONCE ]]; then
^-- SC1046 (error): Couldn't find 'fi' for this 'if'.
^-- SC1073 (error): Couldn't parse this if expression. Fix to allow more checks.


In Test.sh line 17:
  }
  ^-- SC1047 (error): Expected 'fi' matching previously mentioned 'if'.
   ^-- SC1072 (error): Unexpected keyword/token. Fix any mentioned problems and try again.

For more information:
  https://www.shellcheck.net/wiki/SC1046 -- Couldn't find 'fi' for this 'if'.
  https://www.shellcheck.net/wiki/SC1047 -- Expected 'fi' matching previously...
  https://www.shellcheck.net/wiki/SC1072 -- Unexpected keyword/token. Fix any..

Does the website use a later version? If so, how can I get it?
Using the "eval" line instead works but I would prefer a fixed version.
Thanks

@megaannum
Copy link
Author

SC1089: Also, with regard to SC1089
ShellCheck version 0.10.0
$uname -a
Linux olympia 6.11.11-300.fc41.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 18:38:25
UTC 2024 x86_64 GNU/Linux
$ bash --version
GNU bash, version 5.2.32(1)-release (x86_64-redhat-linux-gnu)

If I paste the code from SC1089:
#!/usr/bin/env bash
coproc COPROC_NAME1 { echo "/directory" ; }
echo "${COPROC_NAME1[0]}"
coproc "COPROC_NAME2" { echo "/directory" ; }
cname="COPROC_NAME_$$"
coproc "$cname" { echo "/directory" ; }

into the file X.sh and run shellcheck I get:
$ shellcheck X.sh

In X.sh line 4:
coproc "COPROC_NAME2" { echo "/directory" ; }
^-- SC1083 (warning): This { is literal. Check expression (missing ;/\n?) or quote it.
^-- SC1089 (error): Parsing stopped here. Is this keyword correctly matched up?

For more information:
https://www.shellcheck.net/wiki/SC1083 -- This { is literal. Check expressi...
https://www.shellcheck.net/wiki/SC1089 -- Parsing stopped here. Is this key...

So, SC1089 does not seem to be fixed.

@megaannum
Copy link
Author

previous comment add: SC1089: bash: coproc "NAME" { ...; } - quoted NAME kills parsing #3048

@brother
Copy link
Collaborator

brother commented Jan 20, 2025

Does the website use a later version? If so, how can I get it?

yes. the web uses the latest git HEAD, there are build instructions in the README.

@megaannum
Copy link
Author

megaannum commented Jan 20, 2025 via email

@brother
Copy link
Collaborator

brother commented Jan 20, 2025

Thanks. Just finished compiling/testing and it works.
BTW, you might add to the README build instructions that ghc also has to be installed.

What system did not have it as a hard dependency?
The documentation for cabal-install is pretty clear that ghc will be needed. A PR with a better language is welcome as always, not sure it really is needed myself.

@megaannum
Copy link
Author

megaannum commented Jan 20, 2025 via email

@brother
Copy link
Collaborator

brother commented Jan 20, 2025

And it's in the very first line of the quick start guide of cabal-install.

Start by installing the cabal executable (see the previous section) and the Haskell compiler ghc.

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

2 participants