{"action":"created","issue":{"url":"https://api.github.com/repos/TACC/Lmod/issues/76","repository_url":"https://api.github.com/repos/TACC/Lmod","labels_url":"https://api.github.com/repos/TACC/Lmod/issues/76/labels{/name}","comments_url":"https://api.github.com/repos/TACC/Lmod/issues/76/comments","events_url":"https://api.github.com/repos/TACC/Lmod/issues/76/events","html_url":"https://github.com/TACC/Lmod/pull/76","id":108418579,"number":76,"title":"Also escape $ in shell variables","user":{"login":"opoplawski","id":814662,"avatar_url":"https://avatars.githubusercontent.com/u/814662?v=3","gravatar_id":"","url":"https://api.github.com/users/opoplawski","html_url":"https://github.com/opoplawski","followers_url":"https://api.github.com/users/opoplawski/followers","following_url":"https://api.github.com/users/opoplawski/following{/other_user}","gists_url":"https://api.github.com/users/opoplawski/gists{/gist_id}","starred_url":"https://api.github.com/users/opoplawski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/opoplawski/subscriptions","organizations_url":"https://api.github.com/users/opoplawski/orgs","repos_url":"https://api.github.com/users/opoplawski/repos","events_url":"https://api.github.com/users/opoplawski/events{/privacy}","received_events_url":"https://api.github.com/users/opoplawski/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2015-09-25T22:36:40Z","updated_at":"2016-08-08T18:57:53Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/TACC/Lmod/pulls/76","html_url":"https://github.com/TACC/Lmod/pull/76","diff_url":"https://github.com/TACC/Lmod/pull/76.diff","patch_url":"https://github.com/TACC/Lmod/pull/76.patch"},"body":"I've been playing around with trying to manipulate a user's prompt when loading a modulefile. However, we have a tricky prompt that uses the __git_ps1 function to show the git branch in the prompt:\r\n~~~~~\r\nexport PS1='[\\u@\\h \\W$(__git_ps1 \" (%s)\")]\\$ '\r\n~~~~~\r\nIf we do a pushenv('PS1',..) in a modulefile, on unload we get:\r\n~~~~~\r\nbash: command substitution: line -48: syntax error near unexpected token `('\r\nbash: command substitution: line -48: `__git_ps1 \\\" (%s)\\\")]\\\\$ \"'\r\n~~~~~\r\naccording to set -x, lmod is emitting:\r\n~~~~~\r\n'PS1=\"[\\\\u@\\\\h' '\\\\W$(__git_ps1' '\\\"' '(%s)\\\")]\\\\$' '\";' export 'PS1;'\r\n~~~~~\r\nwhich just doesn't work. module --debug shows:\r\n~~~~~\r\npushenv(PS1, (conda/prompt)nil){\r\nMasterControl:popenv(\"PS1\", \"(conda/prompt)nil\"){\r\nstackName: __LMOD_STACK_PS1 pop()\r\nVar:prt((1) Var:pop()){\r\nname: \"__LMOD_STACK_PS1\"\r\nimin: \"1\"\r\nimax: \"2\"\r\nvalue: \"KGNvbmRhL3Byb21wdCluaWw=:W1x1QFxoIFxXJChfX2dpdF9wczEgIiAoJXMpIildXCQg\"\r\n\"KGNvbmRhL3Byb21wdCluaWw=\": {1, 0}\r\n\"W1x1QFxoIFxXJChfX2dpdF9wczEgIiAoJXMpIildXCQg\": {2, 0}\r\n\r\n} Var:prt\r\nv: 1, imin: 1, min2: inf\r\nv: 2, imin: 1, min2: inf\r\nimin: 1, min2: 2\r\nVar:prt((2) Var:pop()){\r\nname: \"__LMOD_STACK_PS1\"\r\nimin: \"2\"\r\nimax: \"2\"\r\nvalue: \"KGNvbmRhL3Byb21wdCluaWw=:W1x1QFxoIFxXJChfX2dpdF9wczEgIiAoJXMpIildXCQg\"\r\n\"W1x1QFxoIFxXJChfX2dpdF9wczEgIiAoJXMpIildXCQg\": {2, 0}\r\n\r\n} Var:prt\r\nv: [\\u@\\h \\W$(__git_ps1 \" (%s)\")]\\$\r\n} MasterControl:popenv\r\n\r\nBaseShell:expand(tbl){\r\n...\r\nPS1=\"[\\\\u@\\\\h \\\\W$(__git_ps1 \\\" (%s)\\\")]\\\\$ \";\r\n~~~~~\r\nThis is with Lmod 6.0.10.\r\n\r\nLooks like it is using the lua %q format option to format the string, but this isn't working in this case.\r\n\r\nLooks like %q is not escaping $ which needs to be done. This works:\r\n~~~~~\r\nPS1=\"[\\\\u@\\\\h \\\\W\\$(__git_ps1 \\\" (%s)\\\")]\\\\\\$ \";\r\n~~~~~\r\nSo this PR adds that quoting.  This also allows setenv('VAR','a$b') to work.\r\n"},"comment":{"url":"https://api.github.com/repos/TACC/Lmod/issues/comments/238340718","html_url":"https://github.com/TACC/Lmod/pull/76#issuecomment-238340718","issue_url":"https://api.github.com/repos/TACC/Lmod/issues/76","id":238340718,"user":{"login":"rtmclay","id":2041448,"avatar_url":"https://avatars.githubusercontent.com/u/2041448?v=3","gravatar_id":"","url":"https://api.github.com/users/rtmclay","html_url":"https://github.com/rtmclay","followers_url":"https://api.github.com/users/rtmclay/followers","following_url":"https://api.github.com/users/rtmclay/following{/other_user}","gists_url":"https://api.github.com/users/rtmclay/gists{/gist_id}","starred_url":"https://api.github.com/users/rtmclay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rtmclay/subscriptions","organizations_url":"https://api.github.com/users/rtmclay/orgs","repos_url":"https://api.github.com/users/rtmclay/repos","events_url":"https://api.github.com/users/rtmclay/events{/privacy}","received_events_url":"https://api.github.com/users/rtmclay/received_events","type":"User","site_admin":false},"created_at":"2016-08-08T18:57:53Z","updated_at":"2016-08-08T18:57:53Z","body":"I am sorry it has taking me so long to handle this issue.  I have modified Lmod to support quoting $ in shell variables.  This is version is now HEAD.  When you get a chance please test out this new version.\r\n\r\nThanks,\r\nR.\r\n"}}
{"actor":{"display_login":"rtmclay"}}