quoteAliasValue single-quotes an alias value so it is passed verbatim to the shell's `alias` builtin, escaping any embedded quotes for the current shell.
(value string)
| 383 | // quoteAliasValue single-quotes an alias value so it is passed verbatim to the |
| 384 | // shell's `alias` builtin, escaping any embedded quotes for the current shell. |
| 385 | func (s *DevboxShell) quoteAliasValue(value string) string { |
| 386 | if s.name == shFish { |
| 387 | // Inside fish single quotes, only \\ and \' are escape sequences. |
| 388 | value = strings.ReplaceAll(value, `\`, `\\`) |
| 389 | value = strings.ReplaceAll(value, `'`, `\'`) |
| 390 | return "'" + value + "'" |
| 391 | } |
| 392 | // POSIX shells (bash/zsh/ksh): close the quote, emit an escaped quote, |
| 393 | // then reopen, i.e. ' -> '\''. |
| 394 | value = strings.ReplaceAll(value, `'`, `'\''`) |
| 395 | return "'" + value + "'" |
| 396 | } |
| 397 | |
| 398 | // setupShellStartupFiles creates initialization files for the shell by sourcing the user's originals. |
| 399 | // We do this instead of linking or copying, so that we can set correct ZDOTDIR when sourcing |