ShellQuote(3) User Contributed Perl Documentation ShellQuote(3)

# [NAME](#NAME)

String::ShellQuote - quote strings for passing through the shell

# [SYNOPSIS](#SYNOPSIS)

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

# [DESCRIPTION](#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.

[**shell\_quote** \[*string*\]...](#shell_quote)

**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 *string*s are given an empty string is returned.

If any *string* can't be safely quoted **shell\_quote** will **croak**.

[**shell\_quote\_best\_effort** \[*string*\]...](#shell_quote_best_effort)

This is like **shell\_quote**, excpet if the string can't be safely quoted it does the best it can and returns the result, instead of dying.

[**shell\_comment\_quote** \[*string*\]](#shell_comment_quote)

**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. I haven't done this yet because I'm not sure if the *string*s should be joined with blanks ($") or nothing ($,). Cast your vote today! Be sure to justify your answer.

# [EXAMPLES](#EXAMPLES)

```
    $cmd = 'fuser 2>/dev/null ' . shell_quote @files;
    @pids = split ' ', `$cmd`;
    print CFG "# Configured by: ",
                shell_comment_quote($ENV{LOGNAME}), "\n";
```

# [BUGS](#BUGS)

Only Bourne shell quoting is supported. I'd like to add other shells (particularly cmd.exe), but I'm not familiar with them. It would be a big help if somebody supplied the details.

# [AUTHOR](#AUTHOR)

Roderick Schertler &lt;*roderick@argon.org*&gt;

# [SEE ALSO](#SEE_ALSO)

[**perl**(1)](/man/os/perl-string-shellquote/perl.1).

2026-10-25 perl v5.44.0

---

Document: String::ShellQuote(3pm) from perl-string-shellquote 1.04-r7 (Chainguard OS)
Source: https://github.com/gitpan/String-ShellQuote
