Skip to main content

shell_word

Function shell_word 

Source
pub fn shell_word(path: &Path) -> String
Expand description

What: The path as one shell word that a copied command line reads back as exactly that path. Why: The note below gives a command to paste, and a Git directory can sit under a name with spaces, quotes or bytes that are not UTF-8; a word cut by one of them would remove a different path. Text goes in single quotes, where only the quote itself needs the '\'' spelling; bytes that are not UTF-8 go in the $'...' form that bash, zsh and ksh read, with octal escapes for every byte outside plain printable ASCII.

In TS you’d write (pseudocode):

`'${path.replaceAll("'", "'\\''")}'`