The cl-shellwords Reference Manual

Table of Contents

Next: , Previous: , Up: (dir)   [Contents][Index]

The cl-shellwords Reference Manual

This is the cl-shellwords Reference Manual, version 0.1, generated automatically by Declt version 2.3 "Robert April" on Wed Mar 14 03:32:50 2018 GMT+0.


Next: , Previous: , Up: Top   [Contents][Index]

1 Introduction

cl-shellwords

Build Status Quicklisp

CL-shellwords is a port of Ruby's shellwords.rb to Common Lisp. It can be used to escape strings for use on the (Bourne) shell, or to split command lines into segments according to the shell's escaping rules.

Dependencies

CL-shellwords depends only on CL-PPCRE (BSD). The tests additionally depend on Prove (MIT).

Documentation

CL-shellwords defines the package :cl-shellwords, with the alias :shellwords. This package exports three functions, a condition and an accessor for that condition.

SPLIT

(split string)

Split STRING into a list of words, handling escaping the same way a shell like the Bourne shell does.

Whitespace normally acts as a word separator, except when preceded by a backslash or enclosed in single- or double quotes.

Examples:
(split "example string")
;=> ("example"  "string")
(split "example\ escaped string")
;=> ("example escaped" "string")
(split "example 'escaped string'")
;=> ("example" "escaped string")
(split "example "escaped string"")
;=> ("example" "escaped string")

If STRING contains non-matching single- or double quotes, an error of type UNMATCHED-QUOTE-ERROR is signaled. STRING can be retrieved from the error object using UNMATCHED-QUOTE-ERROR-STRING.

ESCAPE

(escape string)

Escape STRING so that it is safe when used as an argument in a shell like the Bourne shell.

Examples:

(escape "")
;=> "''"
(escape "It's an example string")
;=> "It\s\ an\ example\ string"
(escape "NothingWrongHere")
;=> "NothingWrongHere"
(escape "{LF}")
;=> "'{LF}'" ({LF} = #\linefeed)

JOIN

(join sequence)

Join the elements of SEQUENCE together, separated by spaces. The elements are first passed to ESCAPE for proper escaping.

SEQUENCE should be a list or vector of strings.

License

Copyright (c) 2015 Joram Schrijver

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Next: , Previous: , Up: Top   [Contents][Index]

2 Systems

The main system appears first, followed by any subsystem dependency.


Previous: , Up: Systems   [Contents][Index]

2.1 cl-shellwords

Author

Joram Schrijver <i@joram.io>

License

MIT

Description

Common Lisp port of Ruby’s shellwords.rb, for escaping and splitting strings to be passed to a shell.

Version

0.1

Dependency

cl-ppcre

Source

cl-shellwords.asd (file)

Component

shellwords.lisp (file)


Next: , Previous: , Up: Top   [Contents][Index]

3 Files

Files are sorted by type and then listed depth-first from the systems components trees.


Previous: , Up: Files   [Contents][Index]

3.1 Lisp


Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.1 cl-shellwords.asd

Location

cl-shellwords.asd

Systems

cl-shellwords (system)


Previous: , Up: Lisp files   [Contents][Index]

3.1.2 cl-shellwords/shellwords.lisp

Parent

cl-shellwords (system)

Location

shellwords.lisp

Packages

cl-shellwords

Exported Definitions
Internal Definitions

+split-regexp+ (special variable)


Next: , Previous: , Up: Top   [Contents][Index]

4 Packages

Packages are listed by definition order.


Previous: , Up: Packages   [Contents][Index]

4.1 cl-shellwords

Source

shellwords.lisp (file)

Nickname

shellwords

Use List

common-lisp

Exported Definitions
Internal Definitions

+split-regexp+ (special variable)


Next: , Previous: , Up: Top   [Contents][Index]

5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


Next: , Previous: , Up: Definitions   [Contents][Index]

5.1 Exported definitions


Next: , Previous: , Up: Exported definitions   [Contents][Index]

5.1.1 Functions

Function: escape STRING

Escape STRING so that it is safe when used as an argument in a shell like the Bourne shell.

- If STRING is an empty string, a pair of single quotes is returned. - An LF character is escaped by placing it in single quotes.
- All other special characters are escaped with a backslash.

Examples:
(escape "") ;=> "”"
(escape "It’s an example string") ;=> "It\s\ an\ example\ string" (escape "NothingWrongHere") ;=> "NothingWrongHere"
(escape "{LF}") ;=> "’{LF}’" ({LF} = #\linefeed)

Package

cl-shellwords

Source

shellwords.lisp (file)

Function: join SEQUENCE

Join the elements of SEQUENCE together, separated by spaces. The elements are first passed to ESCAPE for proper escaping.

SEQUENCE should be a list or vector of strings.

Package

cl-shellwords

Source

shellwords.lisp (file)

Function: split STRING

Split STRING into a list of words, handling escaping the same way a shell like the Bourne shell does.

Whitespace normally acts as a word separator, except when preceded by a backslash or enclosed in single- or double quotes.

Examples:
(split "example string") ;=> ("example" "string") (split "example\ escaped string") ;=> ("example escaped" "string") (split "example ’escaped string’") ;=> ("example" "escaped string") (split "example "escaped string"") ;=> ("example" "escaped string")

If STRING contains non-matching single- or double quotes, an error of type UNMATCHED-QUOTE-ERROR is signaled. STRING can be retrieved from the error object using UNMATCHED-QUOTE-ERROR-STRING.

Package

cl-shellwords

Source

shellwords.lisp (file)


Next: , Previous: , Up: Exported definitions   [Contents][Index]

5.1.2 Generic functions

Generic Function: unmatched-quote-error-string CONDITION
Package

cl-shellwords

Methods
Method: unmatched-quote-error-string (CONDITION unmatched-quote-error)
Source

shellwords.lisp (file)


Previous: , Up: Exported definitions   [Contents][Index]

5.1.3 Conditions

Condition: unmatched-quote-error ()
Package

cl-shellwords

Source

shellwords.lisp (file)

Direct superclasses

simple-error (condition)

Direct methods

unmatched-quote-error-string (method)

Direct slots
Slot: string
Initargs

:string

Readers

unmatched-quote-error-string (generic function)


Previous: , Up: Definitions   [Contents][Index]

5.2 Internal definitions


Previous: , Up: Internal definitions   [Contents][Index]

5.2.1 Special variables

Special Variable: +split-regexp+
Package

cl-shellwords

Source

shellwords.lisp (file)


Previous: , Up: Top   [Contents][Index]

Appendix A Indexes


Next: , Previous: , Up: Indexes   [Contents][Index]

A.1 Concepts

Jump to:   C   F   L  
Index Entry  Section

C
cl-shellwords.asd: The cl-shellwords<dot>asd file
cl-shellwords/shellwords.lisp: The cl-shellwords/shellwords<dot>lisp file

F
File, Lisp, cl-shellwords.asd: The cl-shellwords<dot>asd file
File, Lisp, cl-shellwords/shellwords.lisp: The cl-shellwords/shellwords<dot>lisp file

L
Lisp File, cl-shellwords.asd: The cl-shellwords<dot>asd file
Lisp File, cl-shellwords/shellwords.lisp: The cl-shellwords/shellwords<dot>lisp file

Jump to:   C   F   L  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.2 Functions

Jump to:   E   F   G   J   M   S   U  
Index Entry  Section

E
escape: Exported functions

F
Function, escape: Exported functions
Function, join: Exported functions
Function, split: Exported functions

G
Generic Function, unmatched-quote-error-string: Exported generic functions

J
join: Exported functions

M
Method, unmatched-quote-error-string: Exported generic functions

S
split: Exported functions

U
unmatched-quote-error-string: Exported generic functions
unmatched-quote-error-string: Exported generic functions

Jump to:   E   F   G   J   M   S   U  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.3 Variables

Jump to:   +  
S  
Index Entry  Section

+
+split-regexp+: Internal special variables

S
Slot, string: Exported conditions
Special Variable, +split-regexp+: Internal special variables
string: Exported conditions

Jump to:   +  
S  

Previous: , Up: Indexes   [Contents][Index]

A.4 Data types

Jump to:   C   P   S   U  
Index Entry  Section

C
cl-shellwords: The cl-shellwords system
cl-shellwords: The cl-shellwords package
Condition, unmatched-quote-error: Exported conditions

P
Package, cl-shellwords: The cl-shellwords package

S
System, cl-shellwords: The cl-shellwords system

U
unmatched-quote-error: Exported conditions

Jump to:   C   P   S   U