Skip to content

Commit

Permalink
[doc/ysh-tour] Mention advanced features, ARGV, ENV
Browse files Browse the repository at this point in the history
- Improve CSS

Still TODO:

- Improve section on Data Notation
- Probably move "Advanced Features" to the appendix
  • Loading branch information
Andy C committed Nov 3, 2024
1 parent ebbcce2 commit 52bebf8
Show file tree
Hide file tree
Showing 4 changed files with 340 additions and 123 deletions.
48 changes: 46 additions & 2 deletions build/doc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -447,14 +447,58 @@ tour() {

# Files used by module example
touch $work_dir/{build,test}.sh

cat >$work_dir/myargs.ysh <<EOF
const __provide__ = :| proc1 p2 p3 |
proc proc1 {
echo proc1
}
proc p2 {
echo p2
}
proc p3 {
echo p3
}
EOF

cat >$work_dir/demo.py <<EOF
#!/usr/bin/env python3
print("hi")
EOF
chmod +x $work_dir/demo.py

cat >$work_dir/lib/util.ysh <<EOF
log() { echo "$@" 1>&2; }
const __provide__ = :| log |
proc log {
echo @ARGV >&2
}
EOF

pushd $work_dir

# Prepend extra code
cat >tour.ysh - $name.txt <<EOF
func myMethod(self) {
echo 'myMethod'
}
func mutatingMethod(self) {
echo 'mutatingMethod'
}
func makeMyObject(x) {
var methods = Object(null, {myMethod, 'M/mutatingMethod': mutatingMethod})
return (Object(methods, {x}))
}
EOF

# Fix: don't supply stdin!
$REPO_ROOT/bin/ysh $name.txt < /dev/null
$REPO_ROOT/bin/ysh tour.ysh < /dev/null
popd

# My own dev tools
Expand Down
12 changes: 12 additions & 0 deletions doc/upgrade-breakage.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@ Shells](known-differences.html).

## Appendix

Here are some notable **non-breaking** changes.

### Shell Functions vs. Procs

Procs have truly local variables like Python and JavaScript. There's no
Expand All @@ -192,6 +194,16 @@ Procs have truly local variables like Python and JavaScript. There's no
This is something to be aware of, but isn't technically a breakage because
shell functions still work the same way in YSH.

### $EDITOR vs. ENV.EDITOR

In YSH, env vars live in the [ENV][] dict. So instead of `$EDITOR`, you should
use `$[ENV.EDITOR]`.

But doesn't break when you `shopt --set ysh:upgrade`, only when you use
`bin/ysh`.

[ENV]: ref/chap-special-var.html#ENV

### Acknowledgments

Thank you to `ca2013` for reviewing this doc.
Expand Down
Loading

0 comments on commit 52bebf8

Please sign in to comment.