I have an application which I am integrating with that accepts the password via a CLI. I am running in to issues with passwords that contain special characters. I tried to escape them all, but I ran in to an issue where I cannot escape the characters
-
'
-
[
-
]
My attempt is as follows:
$ echo '`~!@#$%^&*()-_=+{}\|;:",<.>/?' | sed 's/[`~!@#$%^&*()-_=+{}\|;:",<.>/?]/\\&/g'
\`\~\!\@\#\$\%\^\&\*\(\)\-\_\=\+\{\}\\\|\;\:\"\,\<\.\>\/\?
If I add [
or ]
it obviously breaks my sed logic.
If I add '
it obviously causes errors in sed as it ruins the sed format and the unexpected '
later (which should remain)
If this is not possible, I will tell the client, all characters are acceptable, but generate passwords without '
[
or ]
.
I wonder.... maybe I escape EVERY SINGLE Character? I'd have to test the app... and still not sure how I can do that with sed properly? Is that the solution... not sure.
Please let me know if you can help.
Thank you!