xsh

xsh - XML Editing Shell

SYNOPSIS

xsh [options] script_or_command
xsh [options] -al script [arguments ...]
xsh [options] -aC command [arguments ...]
xsh [options] -p commands < input.xml > output.xml
xsh [options] -I input.xml -O output.xml commands
xsh [options] -P file.xml commands
xsh [options] -cD compiled_script.pl ...

xsh -u          for usage
xsh -h          for help
xsh --man       for the manual page

DESCRIPTION

XSH is an shell-like language for XPath-oriented editing, querying and manipulation of XML and HTML files (with read-only support for DocBook SGML). xsh can work as an interactive shell (with full command-line support such as history, TAB-completion, etc.) or as an off-line interpreter for batch processing of XML files.

XSH COMMANDS

See XSH2 manual page or http://xsh.sourceforge.net/documentation.html for a complete XSH language reference.

For a quick help, type xsh help (just help on xsh prompt).

Type xsh help commands to get list of available XSH commands and xsh help command with command replaced by a XSH command name to get help on a particular command.

SHELL PROMPT

Run xsh help Prompt to get information on how to setup the XSH2 shell prompt.

OPTIONS

--load|-l script-file

Load and execute given XSH script (the script is executed before all other commands provided on the command-line, but after executed ~/.xsh2rc).

--commands|-C

Indicate, that the command-line arguments are XSH commands.

--arguments|-a

Indicate, that the command-line arguments are should be passed to the script via @ARGV (in XML::XSH2::Map namespace). If used with --commands or without --load, the first argument should contain XSH commands and the rest are the passed to via @ARGV.

--files|-F

Indicate, that the command-line arguments should be treated as input filenames. If used with --commands or without --load, the first argument should contain XSH commands. A XSH script specified with --load or XSH commands specified with --commands (or both in this order) are evaluated repeatedly on each input file. For example, running

$ xsh -l script.xsh -FC command file1.xml file2.xml ...

is equivalent to

$ xsh --stdin -aC command file1.xml file2.xml ...
 for $INPUT_FILENAME in { @ARGV } {
   $INPUT := open $INPUT_FILENAME;
   . "script.xsh";
   command
 }
 ^D
--stdin|-t

Don't display command-prompt even if run from a terminal, expecting XSH commands in the standard input.

--compile|-c

Compile the XSH source and report errors, only. No commands are actually executed.

--dump|-D output_filename.pl

Compiles XSH source(s) into a stand-alone Perl script which can be executed simply with

perl output_filename.pl [script-arguments ... ]

The compiled Perl script still requires XML::XSH2 modules to be installed, but since it is already precompiled and also because loading of XSH grammar parser is not required, it starts almost instantly, compared to its XSH source.

Note that the compiled script includes init file (unless -f flag was used), and it also preserves run-time flag settings used during the compilation.

Use -c to suppress execution of the compiled script.

--quiet|-q

Quiet mode: suppress all unnecessary informatory ouptut.

--format

Start with indent 1 (on) and keep_blanks 0 (off) to allow nice indenting of the XML output.

--validation|-v

Start with validation, load_ext_dtd, parser_expands_entities and parser_completes_attributes 1 (on).

--no-validation|-w

Start with validation, load_ext_dtd, parser_expands_entities and parser_completes_attributes 0 (off).

--debug|-d

Print some debug messages.

--no-init|-f

Ignore ~/.xsh2rc

--version|-V

Print XSH version info and exit.

--interactive|-i

Start interactive mode with xsh command prompt. By default, the interactive mode is only started if xsh is running from a terminal and neither XSH commands nor a script are given on the command-line.

--non-interactive|-n

Force non-interactive mode.

--pipe|-p

This is a special mode in which xsh acts as a pipe-line processing tool. In this mode, first the standard input is read and opened as a document _ (underscore), then all XSH commands given in ~/.xsh2rc, command-line and given XSH scripts are applied and finally the (possibly modified) document _ is dumped back on the standard output. It is equivallent to -I - -O - and -P -.

--input|-I filename

Preload given file as a document with ID _ upon startup.

--output|-O filename

Try to saves document with ID _ into given file before XSH ends.

--process|-P filename

A convenient shortcut for -I filename -O filename.

--html|-H

Make XSH expect HTML documents by default in all open/save operations.

--xml|-X

This option is included only for completeness sake. Make XSH expect XSH documents by default in all open/save operations (this is the default).

--trace-grammar|-T

This option allows tracing the way XSH language parser processes your script.

--query-encoding|-E encoding

Set the encoding that used in the XSH scripts (or keyboard input).

--encoding|-e encoding

Set the encoding that should be used for XSH output.

--usage|-u

Print a brief help message on usage and exits.

--help|-h

Prints the help page and exits.

--man

Displays the help as manual page.

AUTHOR

Petr Pajas <pajas@matfyz.cz>

Copyright 2000-2011 Petr Pajas, 2012-2023 E. Choroba. All rights reserved.

SEE ALSO

XSH2, XML::XSH2, XML::XSH2::Compile, XML::LibXML, XML::XUpdate, http://xsh.sourceforge.net/doc