ShellQuote(3)

✨ NAME ✨

okay so bestie, this is the ShellQuote(3) page β€” filed under User Contributed Perl Documentation 🫢 β€” and the module is String::ShellQuote: quote strings for passing through the shell πŸ’…βœ¨


πŸ¦‹ SYNOPSIS πŸ¦‹

           $string = shell_quote @list;
           $string = shell_quote_best_effort @list;
           $string = shell_comment_quote $string;

πŸ’– DESCRIPTION πŸ’–

This module contains some functions which are useful for quoting strings which are going to pass through the shell or a shell-like object 🌈. It’s giving β€œplease don’t let the shell eat my argument” energy, and honestly? Iconic.

πŸ’… shell_quote [string]...

shell_quote quotes strings so they can be passed through the shell. Each string is quoted so that the shell will pass it along as a single argument and without further interpretation πŸŽ€. If no strings are given, an empty string is returned β€” yes, empty string, no cap.

If any string can’t be safely quoted, shell_quote will croak 😭.

🌸 shell_quote_best_effort [string]...

This is like shell_quote, except if the string can’t be safely quoted it does the best it can and returns the result, instead of dying 🫢. Bestie effort, literally.

πŸ¦‹ shell_comment_quote [string]

shell_comment_quote quotes the string so that it can safely be included in a shell-style comment (the current algorithm is that a sharp character is placed after any newlines in the string) πŸ’¬.

This routine might be changed to accept multiple string arguments in the future. The author hasn’t done this yet because they’re not sure if the strings should be joined with blanks ($") or nothing ($,) πŸ€”. Cast your vote today! Be sure to justify your answer β€” iykyk.


πŸ”₯ EXAMPLES πŸ”₯

           $cmd = 'fuser 2>/dev/null ' . shell_quote @files;
           @pids = split ' ', `$cmd`;

           print CFG "# Configured by: ",
                       shell_comment_quote($ENV{LOGNAME}), "\n";

πŸ’€ BUGS πŸ’€

Only Bourne shell quoting is supported 🫠. The author would like to add other shells (particularly cmd.exe), but they’re not familiar with them. It would be a big help if somebody supplied the details β€” bestie, if that’s you, come through πŸ™.


πŸ‘‘ AUTHOR πŸ‘‘

Roderick Schertler <roderick@argon.org> πŸ’Œ


🌈 SEE ALSO 🌈


πŸ’– xoxo, this ShellQuote(3) page is from perl v5.42.0, dated 2018-01-19 β€” mwah, slay, bye πŸŽ€

πŸ“¦ where this page comes from