From 7ddecde54372c25fcf526e2d24807c5dac9800aa Mon Sep 17 00:00:00 2001 From: axel Date: Tue, 20 Sep 2005 23:31:55 +1000 Subject: Add subdirectories darcs-hash:20050920133155-ac50b-9a14c6c664dd03afbe8e15e7c7998fcfb5c3c750.gz --- doc_src/function.txt | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 doc_src/function.txt (limited to 'doc_src/function.txt') 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 + function NAME; BODY; end + +\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 + +
+function hi
+	echo hello
+end
+
+ +will write hello whenever the user enters \c hi. + +If the user enters any additional arguments after the function, they +are inserted into the environment variable array argv. + +\subsection function-example Example + +
function ll 
+	ls -l $argv
+
+ +will run the \c ls command, using the \c -l option, while passing on any additional files and switches to \c ls. + +
+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
+
+ +will run the mkdir command, and if it is succesfull, change the +current working directory to the one just created. + -- cgit v1.2.3