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

Fails on commands named "pass" #24

Closed
utdemir opened this issue Feb 25, 2021 · 8 comments
Closed

Fails on commands named "pass" #24

utdemir opened this issue Feb 25, 2021 · 8 comments

Comments

@utdemir
Copy link

utdemir commented Feb 25, 2021

When you use a command named pass (eg. from password-store) in a script, it crashes resholve:

$ cat test.sh 
pass
$ resholve ./test.sh --interpreter none --path ""
Traceback (most recent call last):
  File "/nix/store/bw25mwzbxyyxk9djlsvfrk4jz2kf4hyz-resholve-0.4.2/bin/.resholve-wrapped", line 1962, in <module>
    sys.exit(punshow())
  File "/nix/store/bw25mwzbxyyxk9djlsvfrk4jz2kf4hyz-resholve-0.4.2/bin/.resholve-wrapped", line 621, in punshow
    epilogue=args.epilogue,
  File "/nix/store/bw25mwzbxyyxk9djlsvfrk4jz2kf4hyz-resholve-0.4.2/bin/.resholve-wrapped", line 485, in resolve_script
    script_path, shebang=shebang, prologue=prologue, epilogue=epilogue
  File "/nix/store/bw25mwzbxyyxk9djlsvfrk4jz2kf4hyz-resholve-0.4.2/bin/.resholve-wrapped", line 1375, in __init__
    self._make_parser(parse_ctx, script, arena)
  File "/nix/store/9y21a7f4a91l1hjkzrrdjpdhar86jwym-python2.7-oildev-unstable-2020-03-31/lib/python2.7/site-packages/oil/core/main_loop.py", line 188, in ParseWholeFile
    node = c_parser.ParseLogicalLine()  # can raise ParseError
  File "/nix/store/9y21a7f4a91l1hjkzrrdjpdhar86jwym-python2.7-oildev-unstable-2020-03-31/lib/python2.7/site-packages/oil/osh/cmd_parse.py", line 2039, in ParseLogicalLine
    node = self._ParseCommandLine()
  File "/nix/store/9y21a7f4a91l1hjkzrrdjpdhar86jwym-python2.7-oildev-unstable-2020-03-31/lib/python2.7/site-packages/oil/osh/cmd_parse.py", line 1901, in _ParseCommandLine
    child = self.ParseAndOr()
  File "/nix/store/9y21a7f4a91l1hjkzrrdjpdhar86jwym-python2.7-oildev-unstable-2020-03-31/lib/python2.7/site-packages/oil/osh/cmd_parse.py", line 1831, in ParseAndOr
    child = self.ParsePipeline()
  File "/nix/store/9y21a7f4a91l1hjkzrrdjpdhar86jwym-python2.7-oildev-unstable-2020-03-31/lib/python2.7/site-packages/oil/osh/cmd_parse.py", line 1777, in ParsePipeline
    child = self.ParseCommand()
  File "/nix/store/9y21a7f4a91l1hjkzrrdjpdhar86jwym-python2.7-oildev-unstable-2020-03-31/lib/python2.7/site-packages/oil/osh/cmd_parse.py", line 1707, in ParseCommand
    enode = self.w_parser.ParseCommandExpr()
  File "/nix/store/9y21a7f4a91l1hjkzrrdjpdhar86jwym-python2.7-oildev-unstable-2020-03-31/lib/python2.7/site-packages/oil/osh/word_parse.py", line 892, in ParseCommandExpr
    grammar_nt.command_expr)
  File "/nix/store/9y21a7f4a91l1hjkzrrdjpdhar86jwym-python2.7-oildev-unstable-2020-03-31/lib/python2.7/site-packages/oil/frontend/parse_lib.py", line 365, in ParseOilExpr
    pnode, last_token = self.e_parser.Parse(lexer, start_symbol)
  File "/nix/store/9y21a7f4a91l1hjkzrrdjpdhar86jwym-python2.7-oildev-unstable-2020-03-31/lib/python2.7/site-packages/oil/oil_lang/expr_parse.py", line 297, in Parse
    self.push_parser.setup(start_symbol)
  File "/nix/store/9y21a7f4a91l1hjkzrrdjpdhar86jwym-python2.7-oildev-unstable-2020-03-31/lib/python2.7/site-packages/oil/pgen2/parse.py", line 111, in setup
    self.stack = [_StackItem(self.grammar.dfas[start], 0, newnode)]
AttributeError: 'NoneType' object has no attribute 'dfas'

My uninformed guess is that likely oil's parser cosiders pass a keyword and it returns a different object.

@abathur
Copy link
Owner

abathur commented Feb 26, 2021

The exception is entirely in Oil's code, which usually isn't a great sign, but the pass builtin was removed in oil-0.8.3 for roughly this reason, so I suspect updating oil will be enough to fix this break.

I'll take a look at how much trouble it'll be to move up to at least 0.8.3. This shouldn't take long if the internals resholve depends on haven't shifted, but it might be a longer wait if it also entails some refactoring.

@abathur
Copy link
Owner

abathur commented Feb 27, 2021

will land in nixpkgs with NixOS/nixpkgs#114528

@abathur
Copy link
Owner

abathur commented Mar 6, 2021

@utdemir It looks like this is finally available in unstable, if you've been waiting :)

@utdemir
Copy link
Author

utdemir commented Mar 7, 2021

Awesome @abathur, thanks, I have been waiting for this! It'll be great to get rid of the hack I have once I update my pin :).

@D3vil0p3r
Copy link

@abathur getting the same error when I try to package lbd. How can I know what is the bash command that make resholve crashing?

@D3vil0p3r
Copy link

I guess the issue on lbd script is related to the usage of:
(line 78)

 if [ $[ $D1 * 3600 + $D2 * 60 + $D3 ] -lt $D4 ]
 then
  echo "FOUND"
  METHODS="$METHODS HTTP[Date]"
  break;
 fi

 D4="$[ $D1 * 3600 + $D2 * 60 + $D3 ]"
 if [ $i -eq $[$QUERIES - 1] ]
 then
  echo "NOT FOUND" 
 fi

(line 98)

 if ! cmp .log .nlog &>/dev/null && [ -e .log ]
 then
  echo "FOUND"
  diff .log .nlog | grep -e ">" -e "<"
  METHODS="$METHODS HTTP[Diff]"
  break;
 fi

 cp .nlog .log

 if [ $i -eq $[$QUERIES - 1] ]
 then
  echo "NOT FOUND" 
 fi

For example, the usage of $[$QUERIES - 1] makes resholve to crash.

@abathur
Copy link
Owner

abathur commented Feb 17, 2024

@D3vil0p3r not sure why that would be directly related to this one. Can you open a new issue and include the full error message?

@D3vil0p3r
Copy link

Sure

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

3 participants