logo

Bash Filter

← Back to Filter List

Bash


↓ examples

Runs bash scripts using 'bash' and returns stdout.

Aliases for this filter

  • bash

Converts from file formats:

  • .sh
  • .bash
  • .txt

To file formats:

  • .txt

Available settings:

SettingDescriptionDefault
add-new-filesBoolean or list of extensions/patterns to match.False
added-in-versionDexy version when this filter was first available.
additional-doc-filtersFilters to apply to additional documents created as side effects.{}
additional-doc-settingsSettings to apply to additional documents created as side effects.{}
argsArguments to be passed to the executable.
check-return-codeWhether to look for nonzero return code.True
clargsArguments to be passed to the executable (same as 'args').
command-stringThe full command string.%(prog)s %(args)s "%(script_file)s" %(scriptargs)s
data-typeAlias of custom data class to use to store filter output.generic
envDictionary of key-value pairs to be added to environment for runs.{}
examplesTemplates which should be used as examples for this filter.[u'bash']
exclude-add-new-filesList of patterns to skip even if they match add-new-files.[]
exclude-new-files-from-dirList of directories to skip when adding new files.[]
executableThe executable to be runbash -e
extFile extension to output.None
extension-mapDictionary mapping input extensions to default output extensions.None
helpHelp string for filter, if not already specified as a class docstring.Runs bash scripts using 'bash' and returns stdout.
initial-timeout10
input-extensionsList of extensions which this filter can accept as input.[u'.sh', u'.bash', u'.txt', u'']
install-dir/home/ana/dev/dexy/dexy/filters
keep-originalsWhether, if additional-doc-filters are specified, the original unmodified docs should also be added.False
mkdirA directory which should be created in working dir.None
mkdirsA list of directories which should be created in working dir.[]
nodocWhether filter should be excluded from documentation.False
outputWhether to output results of this filter by default by reporters such as 'output' or 'website'.False
output-extensionsList of extensions which this filter can produce as output.[u'.txt']
override-workspace-exclude-filtersIf True, document will be populated to other workspaces ignoring workspace-exclude-filters.False
path-extensionsstrings to extend path with[]
preserve-prior-data-classWhether output data class should be set to match the input data class.False
record-varsWhether to add code that will automatically record values of variables.False
require-outputShould dexy raise an exception if no output is produced by this filter?False
scriptargsArguments to be passed to the executable.
tagsTags which describe the filter.[u'shell', u'code']
timeout10
use-wdWhether to use a custom working directory when running filter.True
variablesA dictionary of variable names and values to make available to this filter.{}
varsA dictionary of variable names and values to make available to this filter.{}
version-commandCommand to call to return version of installed software.bash --version
windows-version-commandCommand to call on windows to return version of installed software.None
workspace-exclude-filtersFilters whose output should be excluded from workspace.[u'pyg']
workspace-includesIf set to a list of filenames or extensions, only these will be populated to working dir.None
write-stderr-to-stdoutShould stderr be piped to stdout?False

Bash Examples

Here is a simple bash script:

date
pwd

The bash filter runs scripts in bash and returns the output:

- script.sh|bash

Here is the output:

Fri Nov 22 18:20:34 EST 2013
/tmp/tmpFgTL3m/ex/.dexy/work/5d/5d7f6184425b51e032b248a69670d4a6-001-bash

The sh filter runs scripts in sh (dash) and returns the output:

- script.sh|sh

Here is the output:

Fri Nov 22 18:20:35 EST 2013
/tmp/tmpFgTL3m/ex/.dexy/work/84/84e70db12a901882c0b8c139b4020e77-001-sh

The shint filter runs scripts in a bash REPL, so you can see both input and output:

- script.sh|shint

Here is the output:

$ date
Fri Nov 22 18:20:35 EST 2013
$ pwd
/tmp/tmpFgTL3m/ex/.dexy/work/c8/c80482b06f72edd1306125cb2376152b-001-shint

Normally, bash scripts run in a temporary working directory created and populated especially for the filter being run, but if you want to run a bash script which operates on your actual project directory, you can use the use-wd setting like this (this works on any of the bash-related filters):

    - whereami.sh|shint:
        - shint: { 'use-wd' : False }


$ pwd
/tmp/tmpFgTL3m/ex

The default behavior of running in a working directory is intended to allow you to work with dependencies which have already been processed by dexy, and it also is intended to protect your working directory from side effects of running your bash script.

Content © 2013 Dr. Ana Nelson | Site Design © Copyright 2011 Andre Gagnon | All Rights Reserved.