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

<<< "..." causes the entire file to be treated as string #148

Closed
martin-braun opened this issue Feb 16, 2023 · 6 comments
Closed

<<< "..." causes the entire file to be treated as string #148

martin-braun opened this issue Feb 16, 2023 · 6 comments

Comments

@martin-braun
Copy link

The command cat /dev/stdin <<< "hello world" causes the entire file to be treated as string:

Screen Shot 2023-02-16 at 3 32 43 PM

<<< is used to pipe in direct text. This is useful when regular piping isn't working, i.e. on macOS when trying to source a downloaded script and passing arguments to it:

wexec() {
	url="$1"
	shift
	if command -v "curl" > /dev/null 2>&1; then
		\. /dev/stdin <<< "$(curl --proto '=https' --tlsv1.2 -s "$url")"
	elif command -v "wget" > /dev/null 2>&1; then
		\. /dev/stdin <<< "$(wget --secure-protocol=TLSv1_2 -qO- "$url")"
	else
		echo "No curl or wget found." >&2
		return 1
	fi
}

Screen Shot 2023-02-16 at 3 34 55 PM

This is probably related to #140, but it was not fixed for the <<< case.

@verhovsky
Copy link
Collaborator

I typed your code

cat /dev/stdin <<< "hello world"
# test
echo test

into https://tree-sitter.github.io/tree-sitter/playground and it parses it correctly

program [0, 0] - [3, 0]
  redirected_statement [0, 0] - [0, 32]
    body: command [0, 0] - [0, 14]
      name: command_name [0, 0] - [0, 3]
        word [0, 0] - [0, 3]
      argument: word [0, 4] - [0, 14]
    redirect: herestring_redirect [0, 15] - [0, 32]
      string [0, 19] - [0, 32]
  comment [1, 0] - [1, 6]
  command [2, 0] - [2, 9]
    name: command_name [2, 0] - [2, 4]
      word [2, 0] - [2, 4]
    argument: word [2, 5] - [2, 9]

@martin-braun
Copy link
Author

@verhovsky Does the playground use the version 0.20.7 or bleeding edge? #140 was fixed in December, but the last release was in September as I just recognized. It could be that my issue is already covered by #140, but there was no update yet.

@verhovsky
Copy link
Collaborator

@martin-braun
Copy link
Author

@verhovsky Since the playground confirms it is fixed in master, I assume it was fixed with #140. When is the next release planned btw?

Thanks, I will close this and re-open if there are problems with the next release in that regard.

@skovhus
Copy link
Contributor

skovhus commented Feb 17, 2023

Since the playground confirms it is fixed in master, I assume it was fixed with #140. When is the next release planned btw?

See #134. For https://github.com/bash-lsp/bash-language-server we install from the main branch of tree-sitter-bash now.

@martin-braun
Copy link
Author

Thanks, I'm using coc.nvim for LSP stuff, though. I will wait for the release, it's not a blocker. @skovhus

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