Added gitignore entries needed to ignore derived objects generated from full build...
[bash.git] / examples / scripts.noah / aref.bash
blob9b221b851925418c5563535ed8c84a85a7038660
1 # aref.bash --- pseudo-array manipulating routines
2 # Author: Noah Friedman <friedman@prep.ai.mit.edu>
3 # Created 1992-07-01
4 # Last modified: 1993-02-03
5 # Public domain
7 # Conversion to bash v2 syntax done by Chet Ramey
9 # Commentary:
10 # Code:
12 #:docstring aref:
13 # Usage: aref NAME INDEX
15 # In array NAME, access element INDEX (0-origin)
16 #:end docstring:
18 ###;;;autoload
19 function aref ()
21 local name="$1"
22 local index="$2"
24 set -- ${!name}
25 [ $index -ge 1 ] && shift $index
26 echo $1
29 #:docstring string_aref:
30 # Usage: aref STRING INDEX
32 # Echo the INDEXth character in STRING (0-origin) on stdout.
33 #:end docstring:
35 ###;;;autoload
36 function string_aref ()
38 local stuff=${1:$2}
39 echo ${stuff:0:1}
42 provide aref
44 # aref.bash ends here