File tree Expand file tree Collapse file tree 2 files changed +10
-2
lines changed
Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -81,7 +81,7 @@ mod tests {
8181 use crate :: sync:: tests:: repo_init_with_prefix;
8282
8383 fn repo_init ( ) -> Result < ( TempDir , Repository ) > {
84- repo_init_with_prefix ( "gitui $# " )
84+ repo_init_with_prefix ( "gitui $# ' " )
8585 }
8686
8787 #[ test]
Original file line number Diff line number Diff line change @@ -124,7 +124,15 @@ impl HookPaths {
124124 let mut os_str = std:: ffi:: OsString :: new ( ) ;
125125 os_str. push ( "'" ) ;
126126 if let Some ( hook) = hook. to_str ( ) {
127- os_str. push ( hook. replace ( '\'' , "\\ '" ) ) ;
127+ // SEE: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_02_02
128+ // Enclosing characters in single-quotes ( '' ) shall preserve the literal value of each character within the single-quotes.
129+ // A single-quote cannot occur within single-quotes.
130+ const REPLACEMENT : & str = concat ! (
131+ "'" , // closing single-quote
132+ "\\ '" , // one escaped single-quote (outside of single-quotes)
133+ "'" , // new single-quote
134+ ) ;
135+ os_str. push ( hook. replace ( '\'' , REPLACEMENT ) ) ;
128136 } else {
129137 os_str. push ( hook. as_os_str ( ) ) ; // TODO: this doesn't work if `hook` contains single-quotes
130138 }
You can’t perform that action at this time.
0 commit comments