chickadee » posix-utils

Outdated egg!

This is an egg for CHICKEN 4, the unsupported old release. You're almost certainly looking for the CHICKEN 5 version of this egg, if it exists.

If it does not exist, there may be equivalent functionality provided by another egg; have a look at the egg index. Otherwise, please consider porting this egg to the current version of CHICKEN.

posix-utils

Documentation

Miscellaneous Posix related routines.

terminal-info

terminal-info #!optional PORTprocedure

Returns alist of terminal properties for PORT.

: PORT ; output-port ; current-output-port

Known terminal properties:

: name ; string : width ; fixnum : height ; fixnum

get-terminal-size

get-terminal-size #!optional PORTprocedure

Returns terminal size or #f when PORT is not a terminal-port.

: PORT ; output-port

get-terminal-name

get-terminal-name #!optional PORTprocedure

Returns terminal name or #f when PORT is not a terminal-port.

: PORT ; output-port

output-port-width

output-port-width PORT #!optional DEFprocedure

Returns terminal width or DEF when PORT is not a terminal-port.

: PORT ; (or boolean output-port) ; current-output-port

output-port-height

output-port-height PORT #!optional DEFprocedure

Returns terminal height or DEF when PORT is not a terminal-port.

: PORT ; (or boolean output-port)

string-trim-eol

string-trim-eol STRprocedure

Removes last instance of the platform dependent EOL character sequence from the string STR.

software-eol-string

software-eol-stringconstant

Platform dependent EOL character sequence string.

environment-string

environment-string CELLprocedure

Returns "VAR=VAL", where VAR is (car CELL) & VAL is (cdr CELL).

environment-variables->environment-list

environment-variables->environment-list EVSprocedure

Returns a list of "VAR=VAL" from the environment variables association-list EVS.

qs*

(qs* STR [DELIM #\"]) -> stringprocedure

Result like (conc DELIM STR DELIM).

qs-quote

qs-quote OBJprocedure

Returns "'OBJ'".

qs-string

qs-string OBJprocedure

Returns ""OBJ"".

qs-argument

(qs-argument OBJ [LITERAL? [DELIM #\"]]) -> stringprocedure

Returns a quoted, quasiquoted, or evaluated shell argument string.

An OBJ is

'* (quote . *)
quoted * unless LITERAL?
`* (quasiquote . *)
quasiquoted * unless LITERAL?
*
evaluated

A shell quote is

quoted
' string '
quasiquoted
` ,* (unquote *) | ,@* (unquote-splicing *) | * (quote) `
evaluated
" string "

A quasiquoted OBJ is

,* (unquote *)
evaluated *
,@* (unquote-splicing *)
evaluated * #\space ...
* (quote)
quoted *

get-commandline-result

get-commandline-result CMND LINEprocedure

Returns the result of ''shell'' CMND LINE.

CMND is a string.

LINE is a string.

get-command-result

get-command-result CMND ARG ...procedure

Returns the result of ''shell'' CMND ARG ....

CMND is a string.

ARG ... are string ... & processed by qs-argument.

get-echo-result

get-echo-result EXPprocedure

Returns the result of echo "EXP", w/o the echo eol.

EXP is a string.

environment-variable-bound?

environment-variable-bound? NAMEprocedure

Does the environment variable NAME exist with a non-null value?

NAME is a string.

FOO=1 BAR= csi -q -R posix-utils
#;1> (environment-variable-bound? "FOO")
#t
#;2> (environment-variable-bound? "BAR")
#f

environment-variable-true?

(environment-variable-true? NAME [TRUTHS ("y" "yes" "1")]) -> booleanprocedure

Is the environment variable NAME lowercase value in TRUTHS?

NAME is a string. TRUTHS is a (list-of string) recognized as true values.

FOO=1 BAR= csi -q -R posix-utils
#;1> (environment-variable-true? "FOO")
#t
#;2> (environment-variable-true? "BAR")
#f

register-environment-variable-feature!

register-environment-variable-feature! NAMEprocedure

Registers an existing NAME value as a feature. Returns #f or the registered feature symbol.

NAME is a string.

get-shell-variable

get-shell-variable NAMEprocedure

Returns the shell variable NAME value.

NAME is a string.

shell-variable-bound?

shell-variable-bound? NAMEprocedure

Does the shell variable NAME have a non-null value?

NAME is a string.

shell-variable-true?

(shell-variable-true? NAME [TRUTHS ("y" "yes" "1")]) -> booleanprocedure

Is the shell variable NAME lowercase value in TRUTHS?

NAME is a string. TRUTHS is a (list-of string) recognized as true values.

register-shell-variable-feature!

register-shell-variable-feature! NAMEprocedure

Registers an existing NAME value as a feature. Returns #f or the registered feature symbol.

NAME is a string.

#;1> (register-shell-variable-feature! "OSTYPE")
darwin7 ;ymmv

Usage

(require-extension posix-utils)

Author

kon lovett

Version history

1.2.2
Remove fx-utils dependency.

: 1.2.1 : Fix output-port-width & output-port-height. Add get-terminal-name. Change terminal-info alist.

1.2.0
Added terminal-info, get-terminal-size, output-port-width, & output-port-height.
1.1.0
Added string-trim-eol , software-eol-string, environment-variables->environment-list, register-environment-variable-feature!, get-shell-variable, shell-variable-bound?, shell-variable-true?, register-shell-variable-feature!
1.0.0
Created.

License

Copyright (C) 2010-2018 Kon Lovett. All rights reserved.

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 ASIS, 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.

Contents »