Something went wrong. Try again.
Shells in OCaml
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495Attributes on expansions and params.
Using default values:
$ sh -c "echo \${FOOBAR-hello}" hello $ msh -c "echo \${FOOBAR-hello}" hello
Smallest prefix pattern:
$ cat > test.sh << EOF > x="foobar" > echo "\${x#foo}" > echo "\${x#f*}" > echo "\${x#bar}" > EOF
$ sh test.sh bar oobar foobar $ msh test.sh bar oobar foobar
Largest Prefix Pattern:
$ cat > test.sh << EOF > x=/path/to/my/script.sh > echo "\${x##*/}" > EOF
$ sh test.sh script.sh $ msh test.sh script.sh
Smallest suffix pattern:
$ cat > test.sh << EOF > x="foobar" > echo "\${x%bar}" > echo "\${x%o*}" > echo "\${x%foo}" > EOF
$ sh test.sh foo fo foobar $ msh test.sh foo fo foobar
Largest suffix pattern:
$ cat > test.sh << EOF > x=/path/to/my/script.sh > echo "\${x%%*/}" > EOF
$ sh test.sh /path/to/my/script.sh $ msh test.sh /path/to/my/script.sh
Length of param:
$ cat > test.sh <<EOF > foo=hello > echo \${#foo} > EOF
$ sh test.sh 5 $ msh test.sh 5
Assigning on the fly:
$ cat > test.sh << EOF > echo \${FOO:=bar} > echo \$FOO > EOF
$ sh test.sh bar bar $ msh test.sh bar bar