Skip to content

Conversation

@Role92
Copy link

@Role92 Role92 commented Jan 2, 2022

No description provided.

Copy link

@choudhary-akash choudhary-akash left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just remove the quotes around the query variable before echoing it to sed.

fi

query="$(echo $query | sed 's/ /+/g')"
query="$(echo "$query" | sed 's/ /+/g')"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is best not to put quotes around this query variable. Without quotes, if the user entered something like " Suicide Squad " with a bunch of leading and trailing whitespaces, echoing it would automatically remove the leading and trailing spaces and only the space between the words would get replaced by plus sign in the following sed command. So, the output query would be "Suicide+Squad".

Whereas, if you put quotes around the query variable while echoing, it wouldn't remove the extra spaces and all those extra spaces would get converted to plus signs in the following sed command. In this case the output query would be something like "++++++Suicide+Squad++++"

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

Successfully merging this pull request may close these issues.

2 participants