Timeline for Read non-bash variables from a file into bash script
Current License: CC BY-SA 3.0
14 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Feb 23, 2014 at 0:25 | comment | added | MountainX | @Gilles - thanks for all the discussion. I am reading and learning... | |
| Feb 22, 2014 at 23:53 | comment | added | Gilles 'SO- stop being evil' | This is definitely not what the OP wanted. The values are meant to be literal strings, not shell commands. If you try to parse the output as a shell script (which is what the question was about), this runs one of the rm -rf ~ commands (either the first or the second, depending on which of your snippet he chooses). (ping @MountainX, by the way: seriously, DO NOT RUN THIS! It's a gaping security hole.) | |
| Feb 22, 2014 at 23:49 | comment | added | Ketan | @Gilles After putting the line you mentioned in the file along with other lines OP mentioned and running it through the sed expression I get the following for your line: do_not_run_this=''$(rm -rf ~)'"$(rm -rf ~)"'. Not sure how this is not what OP might have wanted. | |
| Feb 22, 2014 at 23:43 | comment | added | Gilles 'SO- stop being evil' | @Ketan So you'd be happy with parsing a file containing do_not_run_this='$(rm -rf ~)'"$(rm -rf ~)"? (DO NOT TRY THIS!) | |
| Feb 22, 2014 at 23:39 | comment | added | Ketan | @Gilles It does retain single and double quotes in the RHS. @Uwe I made changes to treat comments correctly. Everything after # is now removed first. | |
| Feb 22, 2014 at 23:37 | history | edited | Ketan | CC BY-SA 3.0 | deleted 2 characters in body |
| Feb 22, 2014 at 23:27 | comment | added | Uwe | It also handles comments incorrectly (the leading quote is kept, the trailing quote is deleted together with the #). BTW, it's probably useful to delete the comment together with any preceding whitespace. | |
| Feb 22, 2014 at 23:13 | comment | added | Gilles 'SO- stop being evil' | This doesn't handle values containing " or '. | |
| Feb 22, 2014 at 2:47 | history | edited | Ketan | CC BY-SA 3.0 | added 110 characters in body |
| Feb 22, 2014 at 2:42 | vote | accept | MountainX | ||
| Feb 23, 2014 at 0:40 | |||||
| Feb 22, 2014 at 2:37 | history | edited | Ketan | CC BY-SA 3.0 | added 207 characters in body |
| Feb 22, 2014 at 2:34 | comment | added | Ketan | Yep, realized that and made an update. See if it works now. | |
| Feb 22, 2014 at 2:33 | comment | added | MountainX | The result is VAR1"=value1" | |
| Feb 22, 2014 at 2:31 | history | answered | Ketan | CC BY-SA 3.0 |