aboutsummaryrefslogtreecommitdiffhomepage
path: root/doc_src/function.txt
diff options
context:
space:
mode:
authorGravatar axel <axel@liljencrantz.se>2005-09-20 23:31:55 +1000
committerGravatar axel <axel@liljencrantz.se>2005-09-20 23:31:55 +1000
commit7ddecde54372c25fcf526e2d24807c5dac9800aa (patch)
tree1bff6e0ccd096836adb74529d53a6debcf45375b /doc_src/function.txt
parent149594f974350bb364a76c73b91b1d5ffddaa1fa (diff)
Add subdirectories
darcs-hash:20050920133155-ac50b-9a14c6c664dd03afbe8e15e7c7998fcfb5c3c750.gz
Diffstat (limited to 'doc_src/function.txt')
-rw-r--r--doc_src/function.txt48
1 files changed, 48 insertions, 0 deletions
diff --git a/doc_src/function.txt b/doc_src/function.txt
new file mode 100644
index 00000000..aa818493
--- /dev/null
+++ b/doc_src/function.txt
@@ -0,0 +1,48 @@
+\section function function - create a function
+
+\subsection function-synopsis Synopsis
+ <tt>function NAME; BODY; end </tt>
+
+\subsection function-description Description
+
+This builtin command is used to create a new function. A Function is a
+list of commands that will be executed when the name of the function
+is entered. The function
+
+<pre>
+function hi
+ echo hello
+end
+</pre>
+
+will write <tt>hello</tt> whenever the user enters \c hi.
+
+If the user enters any additional arguments after the function, they
+are inserted into the environment variable <a href="index.html#variables-arrays">array</a> argv.
+
+\subsection function-example Example
+
+<pre>function ll
+ ls -l $argv
+</pre>
+
+will run the \c ls command, using the \c -l option, while passing on any additional files and switches to \c ls.
+
+<pre>
+function mkdir -d "Create a directory and set CWD"
+ mkdir $argv
+ if test $status = 0
+ switch $argv[(count $argv)]
+ case '-*'
+
+ case '*'
+ cd $argv[(count $argv)]
+ return
+ end
+ end
+end
+</pre>
+
+will run the mkdir command, and if it is succesfull, change the
+current working directory to the one just created.
+