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

Quotes disappear from arguments when running script through bass #105

Open
aommm opened this issue Jan 13, 2022 · 3 comments
Open

Quotes disappear from arguments when running script through bass #105

aommm opened this issue Jan 13, 2022 · 3 comments

Comments

@aommm
Copy link

aommm commented Jan 13, 2022

Hi,

First of all, this is probably not a bug but more of a support request. Sorry if this is the wrong forum!

Quotes from my input arguments disappear when I run my script though bass, but they remain when I run it through bash.

I have a script:

# my-script.sh
echo $@

When I run it with bash the quotes are preserved (expected):

> bash my-script.sh '{"a":"b"}'
{"a":"b"}

However, when I run it through bass then the quotes disappear (unexpected):

> bass source my-script.sh '{"a":"b"}'
{a:b}
> bass bash my-script.sh '{"a":"b"}'
{a:b}

Would love to get some guidance here! Again, this is probably not a bug in bass, but just a lack of understanding on my part.

@aommm
Copy link
Author

aommm commented Jan 21, 2022

This seems to be caused by passing the '{"a":"b"}' argument through multiple different shells, each shell stripping some of the quotes. In my case, the outermost quotes ' are stripped by fish, and the innermost " are stripped by bash.

I wanted to solve this without forcing the user to write a bunch of \ manually. I managed to create a workaround that works in my case.

Workaround

I'm creating a new fish function myscript that wraps my-script.sh:

function myscript
	# Need to transform {"a":1} into {\"a\":1} before passing to bass
	set quoted_argv (echo "$argv" | sed --expression 's/"/\\\\"/g')
	bass source /path/to/my-script.sh "$quoted_argv"
end

This then works correctly:

> myscript '{"a":"b"}'
{"a":"b"}

@edc
Copy link
Owner

edc commented Jan 31, 2022

Thanks for documenting this. Can we close this then?

@aommm
Copy link
Author

aommm commented Feb 1, 2022

Yep it can!

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