### GUI Test Setup Example Source: https://github.com/oils-for-unix/oils/blob/master/Python-2.7.13/Lib/idlelib/idle_test/README.txt Example of setUpClass for GUI tests, including resource requirement and Tk root creation. ```python import unittest from test.support import requires import tkinter as tk class _Test(unittest.TestCase): @classmethod def setUpClass(cls): requires('gui') cls.root = tk.Tk() cls.text = tk.Text(root) @classmethod def tearDownClass(cls): del cls.text cls.root.destroy() del cls.root ``` -------------------------------- ### Display Install Help Source: https://github.com/oils-for-unix/oils/blob/master/INSTALL.txt Show available options for the Oils installation command. ```bash ./install --help ``` -------------------------------- ### Traditional Oils Installation Source: https://github.com/oils-for-unix/oils/blob/master/INSTALL.txt The standard method for installing Oils involves configuration, building, and then installing the binaries. ```bash ./configure # completes very quickly _build/oils.sh # 30-60 seconds sudo ./install ``` -------------------------------- ### Run Python example directly Source: https://github.com/oils-for-unix/oils/wiki/Oils-Dev-Cheat-Sheet Execute a Python example script within the mycpp directory. Requires PYTHONPATH to be set. ```shell PYTHONPATH=.:mycpp mycpp/examples/parse.py ``` -------------------------------- ### Shellac Registration Example Source: https://github.com/oils-for-unix/oils/wiki/Shellac-Protocol-Proposal Hypothetical example of registering a command for Shellac completion. ```bash complete -S ``` -------------------------------- ### Alpine chroot setup commands Source: https://github.com/oils-for-unix/oils/blob/master/regtest/aports.md Commands to manage the Alpine Linux chroot environment for testing. Use remove-chroot for a clean build, fetch-all to get necessary files, and prepare-all to create the chroot. ```shell regtest/aports-setup.sh remove-chroot # optional; for a CLEAN build ``` ```shell regtest/aports-setup.sh fetch-all # git clone, download Oils from CI ``` ```shell regtest/aports-setup.sh prepare-all # make a chroot ``` ```shell regtest/aports-setup.sh unpack-distfiles main ``` -------------------------------- ### Bash Completion Registration Example Source: https://github.com/oils-for-unix/oils/wiki/Shellac-Protocol-Proposal Example of registering a command for completion using bash's complete command. ```bash complete -C git_completion_command git ``` -------------------------------- ### Install oils-for-unix via Nix Source: https://github.com/oils-for-unix/oils/wiki/Oils-Deployments Reference the oils-for-unix package in Nixpkgs for installation. ```bash pkgs.oils-for-unix ``` -------------------------------- ### Installing Oils to User's Home Directory Source: https://github.com/oils-for-unix/oils/blob/master/INSTALL-old.txt Configures the build with a custom prefix and datarootdir for user-specific installation, compiles, and installs Oils without requiring root access. ```bash ./configure --prefix ~ --datarootdir ~/.local/share make ./install ``` -------------------------------- ### Tcl configuration language example Source: https://github.com/oils-for-unix/oils/blob/master/doc/language-influences.md An example of how Tcl can be used as a configuration language, demonstrating nested blocks for defining changes with author and description. ```tcl change 6/11/2003 { author "Will Duquette" description { Added the SATl component to UCLO. } } ``` -------------------------------- ### Install oil via xbps-install on Void Linux Source: https://github.com/oils-for-unix/oils/wiki/Oils-Deployments Install the old 'oil' tarball on Void Linux using the xbps-install command. ```bash xbps-install oil ``` -------------------------------- ### Python Doctest Silly Setup Source: https://github.com/oils-for-unix/oils/blob/master/Python-2.7.13/Lib/test/test_doctest2.txt Demonstrates a simple setup for doctests in Python. Requires importing the test.test_doctest module. ```python >>> import test.test_doctest >>> test.test_doctest.sillySetup True ``` -------------------------------- ### Date Formatting Example Source: https://github.com/oils-for-unix/oils/wiki/Shell-WTFs An example showing the potential for confusion with single-letter format specifiers in the 'date' command. ```bash date +%m date +%M ``` -------------------------------- ### Install oils-for-unix from Arch User Repository Source: https://github.com/oils-for-unix/oils/wiki/Oils-Deployments Install oils-for-unix from the Arch User Repository using pacman. Replace version and architecture placeholders with actual values. ```bash pacman -U oils-for-unix--.pkg.tar.zst ``` -------------------------------- ### Install Custom Tools (Wedges) Source: https://github.com/oils-for-unix/oils/wiki/Contributing Builds and installs custom tools, referred to as 'wedges', into a directory outside the repository. This step may require root permissions for the `/wedge` directory. ```bash build/deps.sh install-wedges # Build and install wedges in ../oils.DEPS ``` -------------------------------- ### Install oil via Pacstall on Debian/Ubuntu Source: https://github.com/oils-for-unix/oils/wiki/Oils-Deployments Install the old 'oil' tarball using Pacstall on Debian or Ubuntu systems. ```bash pacstall -I oil ``` -------------------------------- ### Installing Oils to /usr/local/bin Source: https://github.com/oils-for-unix/oils/blob/master/INSTALL-old.txt Configures the build, compiles the code, and installs Oils to the default /usr/local/bin/osh location using sudo. ```bash ./configure make sudo ./install ``` -------------------------------- ### Install Wedges and Build Oil-Native Source: https://github.com/oils-for-unix/oils/blob/master/mycpp/README.md Installs build components ('wedges') and then compiles the oil-native C++ version using Ninja. This step translates Python to C++ and links the final executable. ```bash oil$ build/deps.sh install-wedges oil$ ./NINJA-config.sh oil$ ninja # translate and compile, may take 30 seconds ``` -------------------------------- ### Install oils-for-unix and replace /bin/sh on Alpine Linux Source: https://github.com/oils-for-unix/oils/wiki/Oils-Deployments Install oils-for-unix on Alpine Linux and optionally replace the default /bin/sh. ```bash apk add oils-for-unix-binsh ``` -------------------------------- ### Getting Start Position of Regex Capture Groups Source: https://github.com/oils-for-unix/oils/blob/master/doc/ref/chap-type-method.md Illustrates how to obtain the starting index of a regex capture group, including named groups. ```Oil var m = '10:59'.search(/ ':' /) echo $[m.start(0)] # => position 2 for ':59' echo $[m.start(1)] # => position 3 for '59' echo $[m.start('minute')] # => position 3 for '59' ``` -------------------------------- ### Setup and Fetch Distributions Source: https://github.com/oils-for-unix/oils/blob/master/regtest/aports.md Fetch all necessary distribution files for package building. ```bash regtest/aports-setup.sh fetch-all ``` -------------------------------- ### Shell Comment Example Source: https://github.com/oils-for-unix/oils/blob/master/doc/ref/chap-front-end.md A comment in Oils starts with '#' and extends to the end of the line. ```shell echo hi # print a greeting ``` -------------------------------- ### Fetch and Prepare Aports Chroot Source: https://github.com/oils-for-unix/oils/wiki/Tips-on-Reducing-Bugs-to-Small-Test-Cases Use these commands to fetch the aports repository and prepare the chroot environment for testing. The `prepare-all` command sets up OverlayFS with oils-for-unix. ```bash regtest/aports-setup.sh fetch-all # git clone aports, etc. regtest/aports-setup.sh prepare-all # runs alpine-chroot-install script # also sets up OverlayFS dir with oils-for-unix ``` -------------------------------- ### Example argv command output Source: https://github.com/oils-for-unix/oils/blob/master/doc/simple-word-eval.md Demonstrates the output of the 'argv' command, which prints the arguments it receives in a readable format. This is used throughout the examples to show argument processing. ```sh-prompt $ argv one "two three" ['one', 'two three'] ``` -------------------------------- ### ps --format Example Source: https://github.com/oils-for-unix/oils/wiki/Unix-Tools Demonstrates custom formatting for process information using 'ps'. ```bash ps --format="%p %cpu %mem %cmd" ``` -------------------------------- ### Interpreter-Mutated Global Functions Source: https://github.com/oils-for-unix/oils/blob/master/doc/style-guide.md Functions to access interpreter-mutated global variables also start with an underscore (_). This snippet shows examples of such functions. ```ysh _group() _start() _end() ``` -------------------------------- ### Enter Nix Shell and Build Oil Source: https://github.com/oils-for-unix/oils/wiki/Developing-Oil-With-Nix Enter the Nix shell environment and then build all components of the Oil shell. This is the initial setup for development. ```bash $ nix-shell # from your own shell [nix-shell]$ build/dev.sh all ``` -------------------------------- ### Creating an Object Instance with Methods Source: https://github.com/oils-for-unix/oils/blob/master/doc/ref/chap-type-method.md Demonstrates the creation of an object instance with custom methods and properties. This example shows how to define a method and associate it with an object. ```oils func mymethod(self) { return (42) } var methods = Obj.new({methodName: mymethod}, null) var instance = Obj.new({x: 3, y: 4}, methods) ``` -------------------------------- ### Shell For Loop Example Source: https://github.com/oils-for-unix/oils/blob/master/doc/simple-word-eval.md Example of a for loop in shell with variable substitution. ```sh for i in $x foo; do ... ``` -------------------------------- ### Rich Completion Example (ls) Source: https://github.com/oils-for-unix/oils/wiki/Shellac-Protocol-Proposal Demonstrates rich completions for 'ls --a', including descriptions for options. ```text ls --a --all -- list entries starting with . --almost-all -- list all except . and .. --author -- print the author of each file ``` -------------------------------- ### Install Fedora Dependencies Source: https://github.com/oils-for-unix/oils/wiki/Contributing Installs necessary packages for building Python 2 and 3 from scratch on Fedora. This is also tested in the project's CI. ```bash build/deps.sh wedge-deps-fedora # Ditto, should work! ``` -------------------------------- ### YSH Glob and Brace Expansion Examples Source: https://github.com/oils-for-unix/oils/blob/master/doc/syntax-feelings.md Provides examples of using glob characters and brace expansion in YSH for file matching and string generation. ```ysh echo *.[ch] # glob char and char classes ``` ```ysh echo {alice,bob}@example.com # brace expansion ``` -------------------------------- ### Globbing Example Source: https://github.com/oils-for-unix/oils/blob/master/doc/options.md Illustrates globbing behavior, potentially affected by runtime options like simple_word_eval. This example shows how a wildcard pattern expands to match files. ```shell echo $dir/*.py ``` -------------------------------- ### Set -x Example with Two Arguments Source: https://github.com/oils-for-unix/oils/blob/master/doc/qsn.md Illustrates how `set -x` traces command execution when arguments do not contain spaces. ```bash $ set -x $ echo two args + echo two args ``` -------------------------------- ### Redirect Examples Source: https://github.com/oils-for-unix/oils/blob/master/doc/ref/chap-cmd-lang.md Demonstrates different ways to use output redirection, including redirecting to stderr and a file. ```shell echo 'to stderr' >&2 ``` ```shell echo >&2 'to stderr' ``` ```shell echo 'to file' > out.txt ``` ```shell echo > out.txt 'to file' ``` -------------------------------- ### Get Dictionary Value with Default using get() Source: https://github.com/oils-for-unix/oils/blob/master/doc/ref/chap-builtin-func.md Use get() to retrieve a value by its key from a dictionary. It allows specifying a default value to return if the key is not found. The default is null if not provided. ```oil var book = { title: "Hitchhiker's Guide", published: 1979, } var published = get(book, 'published', null) = published # => (Int) 1979 ``` ```oil var author = get(book, 'author', "???'") = author # => (Str) "???'" ``` ```oil var author = get(book, 'author') = author # => (Null) null ``` -------------------------------- ### Initialize Oils Configuration Directories Source: https://github.com/oils-for-unix/oils/blob/master/doc/getting-started.md Create necessary directories for Oils configuration files and history. This is a one-time setup step. ```shell mkdir -p ~/.config/oils # for oshrc and yshrc mkdir -p ~/.local/share/oils # for osh_history ``` -------------------------------- ### Globbing Example Source: https://github.com/oils-for-unix/oils/blob/master/doc/word-eval.txt Demonstrates how globbing is respected within strings. ```bash a='*.py' same as: a=*.py # no globbing yet echo $a ``` -------------------------------- ### Shell Command Completion Examples Source: https://github.com/oils-for-unix/oils/wiki/Shellac-Test-Cases Demonstrates various shell command structures that require dequoting for completion. These examples show pipes, logical AND, and command substitution using both $() and backticks. ```shell ls | wc - ``` ```shell echo hi && wc -l ``` ```shell echo $(dirname f ``` ```shell echo `dirname f ``` -------------------------------- ### Shell Command Example Source: https://github.com/oils-for-unix/oils/blob/master/doc/simple-word-eval.md Example of a simple shell command involving variable substitution. ```sh echo $x foo ``` -------------------------------- ### Display Sample Files Source: https://github.com/oils-for-unix/oils/blob/master/doc/ysh-io.md Shows the beginning of the generated 'lines.txt' and 'j8-lines.txt' files to preview the output. ```sh head lines.txt j8-lines.txt ``` -------------------------------- ### Sourcing Standard Library Files Source: https://github.com/oils-for-unix/oils/blob/master/stdlib/README.md Demonstrates how to source standard library files, including conditional logic based on the environment. ```sh if test -n "${OILS_VERSION:-}"; then prefix='--builtin ' else prefix='stdlib' fi source ${prefix}two.sh source ${prefix}bash-strict.sh ``` -------------------------------- ### Install yapf Formatter Source: https://github.com/oils-for-unix/oils/wiki/Oils-Dev-Cheat-Sheet Installs a specific version of the yapf Python formatter required for the project. ```shell devtools/format.sh install-yapf # install a specific version that we need to agree on ``` -------------------------------- ### Prepare Packages for Building Source: https://github.com/oils-for-unix/oils/blob/master/regtest/aports.md Prepare all packages for the build process. ```bash regtest/aports-setup.sh prepare-all ``` -------------------------------- ### Yaks Function Definition Example Source: https://github.com/oils-for-unix/oils/blob/master/yaks/README.md An example of a Yaks function definition with a typed local variable. ```Yaks (func f [] (var [x Int] 42)) ``` -------------------------------- ### Build and Preview Documentation Source: https://github.com/oils-for-unix/oils/blob/master/doc/doc-toolchain.md Command to build and preview the documentation. Open the generated HTML file in your browser. ```shell build/doc.sh split-and-render doc/doc-toolchain.md ``` -------------------------------- ### YSH Case Statement Example Source: https://github.com/oils-for-unix/oils/blob/master/doc/ref/toc-ysh.md Provides an example of a YSH case statement for pattern matching. ```ysh case (x) { *.py { echo 'python' } } ``` -------------------------------- ### Basic Pipeline Example Source: https://github.com/oils-for-unix/oils/blob/master/doc/ysh-tour.md A simple pipeline demonstrating how to chain commands together, passing the output of one as the input to the next. ```ysh ls | wc -l # count files in this directory ``` -------------------------------- ### YSH Array Literal Example Source: https://github.com/oils-for-unix/oils/blob/master/doc/simple-word-eval.md Example of creating an array literal in YSH with variable substitution. ```ysh var a = :| $x foo | ``` -------------------------------- ### Display Configure Help Source: https://github.com/oils-for-unix/oils/blob/master/INSTALL.txt Show available configuration options for the Oils build process. ```bash ./configure --help ``` -------------------------------- ### Shell Array Literal Example Source: https://github.com/oils-for-unix/oils/blob/master/doc/simple-word-eval.md Example of creating an array literal in shell with variable substitution. ```sh a=($x foo) ``` -------------------------------- ### Brace Expansion Example Source: https://github.com/oils-for-unix/oils/blob/master/doc/ref/chap-mini-lang.md Demonstrates basic brace expansion with comma-separated lists and number ranges. ```shell echo {foo,bar}@example.com ``` ```shell echo foo{1..3} ``` -------------------------------- ### OSH Conditional Example Source: https://github.com/oils-for-unix/oils/blob/master/doc/ref/chap-cmd-lang.md An example of an 'if' statement using OSH style syntax with 'test'. ```shell if test -d /; then echo yes fi ``` -------------------------------- ### Install oils-for-unix via Homebrew Source: https://github.com/oils-for-unix/oils/wiki/Oils-Deployments Install the oils-for-unix package on macOS using the Homebrew package manager. ```bash brew install oils-for-unix ``` -------------------------------- ### Run all code in documentation Source: https://github.com/oils-for-unix/oils/wiki/Oils-Dev-Cheat-Sheet Check the validity of all code examples across the entire documentation. ```shell build/doc.sh run-code-all ``` -------------------------------- ### Non-Root Oils Installation Source: https://github.com/oils-for-unix/oils/blob/master/INSTALL.txt Configure and install Oils to a user-specific directory without requiring root privileges. ```bash ./configure --prefix ~ --datarootdir ~/.local/share _build/oils.sh ./install ``` -------------------------------- ### getopts example with argument Source: https://github.com/oils-for-unix/oils/blob/master/doc/ref/chap-builtin-cmd.md Demonstrates parsing options 'a' and 'b' (which takes an argument) within a while loop. Sets variables 'flag_a' and 'flag_b' based on parsed options. ```sh while getopts "ab:" flag; do case $flag in a) flag_a=1 ;; b) flag_b=$OPTARG" ;; '?') echo 'Invalid Syntax'; break ;; esac done ``` -------------------------------- ### Install Build Dependencies on Debian/Ubuntu Source: https://github.com/oils-for-unix/oils/blob/master/INSTALL.txt Installs the necessary build tools and libraries for Oils on Debian-based systems. ```bash sudo apt-get install build-essential libreadline-dev ``` -------------------------------- ### YSH Conditional Example Source: https://github.com/oils-for-unix/oils/blob/master/doc/ref/chap-cmd-lang.md An example of an 'if' statement using YSH style syntax with curly braces. ```ysh if test --dir / { echo yes } ``` -------------------------------- ### Quoted Lines Examples Source: https://github.com/oils-for-unix/oils/blob/master/doc/ref/chap-j8.md Examples of quoted lines in J8 format, which must be valid J8 strings. ```text "json-style J8 string" ``` ```text b'this is b style' ``` ```text u'this is u style' ``` -------------------------------- ### YSH Command Mode Example Source: https://github.com/oils-for-unix/oils/blob/master/doc/syntactic-concepts.md Demonstrates basic command mode syntax similar to traditional shell. ```ysh echo "hello $name" for i in 1 2 3 { echo $i } ``` -------------------------------- ### Unquoted Lines Examples Source: https://github.com/oils-for-unix/oils/blob/master/doc/ref/chap-j8.md Examples of unquoted lines in J8 format. Leading and trailing whitespace is ignored. ```text foo bar internal "quotes" aren't special ``` ```text C:\Program Files\ ``` -------------------------------- ### JSON String Example Source: https://github.com/oils-for-unix/oils/blob/master/doc/ref/chap-j8.md A standard JSON string example. J8 strings are compatible with JSON strings. ```json "hi μ \n" ``` -------------------------------- ### Set Up Development Environment Source: https://github.com/oils-for-unix/oils/wiki/Contributing Sources the development shell script to place build tools, like a custom Python 2 build, into your PATH. This should be run every time you pull changes or switch branches. ```bash . build/dev-shell.sh # put our build of python2 in your $PATH ``` -------------------------------- ### Example Cloudcopy Command Source: https://github.com/oils-for-unix/oils/wiki/Coprocess-Protocol-Proposal Illustrates the basic usage of a hypothetical cloudcopy command-line tool. ```shell cloudcopy foo.jpg //remote/myhome/mydir/ ``` -------------------------------- ### Display Build Script Help Source: https://github.com/oils-for-unix/oils/blob/master/INSTALL.txt Show available options for the Oils build script. ```bash _build/oils.sh --help ``` -------------------------------- ### Unquoted Variant Example Source: https://github.com/oils-for-unix/oils/wiki/CSTR-Proposal Shows an example of the unquoted variant of CSTR, which is valid when the string does not contain tabs. ```text name age bob 10 ``` -------------------------------- ### Simple Command Examples Source: https://github.com/oils-for-unix/oils/blob/master/doc/ref/chap-cmd-lang.md Illustrates various types of simple commands, including shell builtins, external processes, YSH procedures, shell functions, and aliases. ```shell echo hi # a shell builtin doesn't start a process ``` ```shell ls /usr/bin ~/src # starts a new process ``` ```shell myproc "hello $name" ``` ```shell myshellfunc "hello $name" ``` ```shell myalias -l ``` -------------------------------- ### Install Build Dependencies on Alpine Linux Source: https://github.com/oils-for-unix/oils/blob/master/INSTALL.txt Installs the necessary build tools and libraries for Oils on Alpine Linux. ```bash apk add libc-dev gcc readline-dev ``` -------------------------------- ### Installing Build Dependencies on Debian/Ubuntu Source: https://github.com/oils-for-unix/oils/blob/master/INSTALL-old.txt Installs the necessary build tools and the readline development library on Debian-based systems. ```bash sudo apt install build-essential libreadline-dev ``` -------------------------------- ### JSON8 String Examples Source: https://github.com/oils-for-unix/oils/blob/master/doc/ref/chap-j8.md Examples of JSON8 strings, which support J8 string syntax including Unicode escapes. ```text "hi 🤦 \u03bc" ``` ```text u'hi 🤦 \u{3bc}' ``` ```text b'hi 🤦 \u{3bc} \yff' ``` -------------------------------- ### Basic Commands Source: https://github.com/oils-for-unix/oils/blob/master/doc/proc-func.md Start with plain commands for simple tasks before organizing them into procs. ```sh mkdir -p /tmp/dest cp --verbose *.txt /tmp/dest ``` -------------------------------- ### Front Matter Example Source: https://github.com/oils-for-unix/oils/blob/master/doc/doc-toolchain.md Example of front matter metadata for rendering a document. This section is enclosed by '---' lines. ```yaml --- in_progress: yes default_highlighter: oils-sh --- My Title ======== Hello ``` -------------------------------- ### printf Builtin Example Source: https://github.com/oils-for-unix/oils/wiki/Unix-Tools Shows the usage of the printf builtin command for formatted output. ```bash printf "%s is %d years old\n" "Alice" 30 ``` -------------------------------- ### Inspect All Bash Options Source: https://github.com/oils-for-unix/oils/blob/master/doc/options.md Use `shopt -p` to print the current state of all Bash compatible options. ```sh shopt -p ``` -------------------------------- ### Shellac Response Example Source: https://github.com/oils-for-unix/oils/wiki/Shellac-Protocol-Proposal An example of a Shellac response from a server to a client, providing a list of possible completion candidates. ```json { "candidates": ["add", "am", "annotate", "apply", "archive"] } ``` -------------------------------- ### od Binary Data Formatting Example Source: https://github.com/oils-for-unix/oils/wiki/Unix-Tools Shows how to format binary data using the 'od' command. ```bash od -c binary_file ``` -------------------------------- ### session-ysh Syntax Highlighting Source: https://github.com/oils-for-unix/oils/blob/master/doc/doc-plugins.md Highlights a YSH shell session, including commands starting with `$` and continuation lines starting with `>`. ```session-ysh $ echo one one $ for x in foo bar { > echo $x > } foo bar ``` -------------------------------- ### Multiline Pipeline Example Source: https://github.com/oils-for-unix/oils/blob/master/doc/ref/chap-front-end.md Demonstrates a long pipeline command broken into multiple lines using the '...' prefix. ```shell ... find . # exclude tests | grep -v '_test.py' | xargs wc -l | sort -n ; ``` -------------------------------- ### Define a Parser using Context Source: https://github.com/oils-for-unix/oils/blob/master/doc/ref/chap-builtin-cmd.md This example demonstrates using `ctx` to build a simple argument parser DSL. It defines procedures for parsing arguments and flags within a context. ```oils-shell proc parser (; place ; ; block_def) { var p = {} ctx push (p, block_def) call place->setValue(p) } proc flag (short_name, long_name; type; help) { ctx emit flag ({short_name, long_name, type, help}) } proc arg (name) { ctx emit arg ({name}) } parser (&spec) { flag -t --tsv (Bool, help='Output as TSV') flag -r --recursive (Bool, help='Recurse into the given directory') flag -N --count (Int, help='Process no more than N files') arg path } ``` -------------------------------- ### session-bash Syntax Highlighting Source: https://github.com/oils-for-unix/oils/blob/master/doc/doc-plugins.md Highlights a bash shell session, including commands starting with `$` and continuation lines starting with `>`. ```session-bash $ echo one one $ for x in foo bar; do > echo $x > done foo bar ``` -------------------------------- ### Install Common Development Wedges Source: https://github.com/oils-for-unix/oils/wiki/Oils-Dev-Cheat-Sheet Installs the typical set of dependencies needed for Oil development, similar to the tarball dependencies. ```bash build/deps.sh install-wedges # install what you typically need, as above ``` -------------------------------- ### Set -x Example with Quoted Argument Source: https://github.com/oils-for-unix/oils/blob/master/doc/qsn.md Shows how `set -x` traces command execution when an argument needs quoting to represent a single element with a space. ```bash $ set -x $ x='a b' $ echo "$x" c + echo 'a b' c ``` -------------------------------- ### Install Debian Dependencies for Tarball Source: https://github.com/oils-for-unix/oils/wiki/Oils-Dev-Cheat-Sheet Use this command to install the necessary dependencies on a Debian system for building the tarball dependencies. ```bash build/deps.sh wedge-deps-debian # dependencies to build the tarball dependencies! ``` -------------------------------- ### Set Baseline Configuration Source: https://github.com/oils-for-unix/oils/blob/master/regtest/aports.md Set up the standard Alpine Linux configuration for building. ```bash regtest/aports-run.sh set-baseline ``` -------------------------------- ### Install oils-for-unix and replace /bin/bash on Alpine Linux Source: https://github.com/oils-for-unix/oils/wiki/Oils-Deployments Install oils-for-unix on Alpine Linux and optionally replace the default /bin/bash. ```bash apk add oils-for-unix-bash ``` -------------------------------- ### bash time Builtin Example Source: https://github.com/oils-for-unix/oils/wiki/Unix-Tools Illustrates timing command execution using the bash time builtin. ```bash TIMEFORMAT="It took %R seconds."; time sleep 1 ``` -------------------------------- ### Setup Development Environment Source: https://github.com/oils-for-unix/oils/wiki/Oils-Dev-Cheat-Sheet Run these commands after pulling changes or switching branches to ensure your build environment is up-to-date. This sets up the Python 2 build and makes the interpreted bin/osh and bin/ysh available. ```bash . build/dev-shell.sh build/py.sh all ./NINJA-config.sh ``` -------------------------------- ### Enable DNF Copr and Install oils-for-unix Source: https://github.com/oils-for-unix/oils/wiki/Oils-Deployments Use this command to enable the Fedora/RHEL COPR repository for oils-for-unix and then install the package. ```bash dnf copr enable tkbcopr/oils-for-unix && dnf in oils-for-unix ``` -------------------------------- ### Testmapi.py MAPI Initialization Source: https://github.com/oils-for-unix/oils/blob/master/Python-2.7.13/Tools/freeze/win32.html Initializes MAPI using the MAPI COM extension and prints the computer name. Ensure MAPI is initialized before use and uninitialized afterward. ```python from win32com.mapi import mapi import win32api mapi.MAPIInitialize( (mapi.MAPI_INIT_VERSION, 0) ) print "Hello from", win32api.GetComputerName() mapi.MAPIUninitialize() ``` -------------------------------- ### J8 Unicode Escape Example Source: https://github.com/oils-for-unix/oils/blob/master/doc/ref/chap-j8.md Example of a J8 Unicode escape for a code point outside the Basic Multilingual Plane. ```j8 u'\u{1f926}' ``` -------------------------------- ### xxd Binary Data Formatting Example Source: https://github.com/oils-for-unix/oils/wiki/Unix-Tools Demonstrates formatting binary data into a hex dump using 'xxd'. ```bash xxd binary_file ``` -------------------------------- ### Example Symbols and Lengths Source: https://github.com/oils-for-unix/oils/blob/master/Python-2.7.13/Modules/zlib/algorithm.txt Illustrates the symbols and their corresponding bit lengths used in the deflate algorithm's output. ```text A: 0 B: 10 C: 1100 D: 11010 E: 11011 F: 11100 G: 11101 H: 11110 I: 111110 J: 111111 ``` -------------------------------- ### Basic TSV Example Source: https://github.com/oils-for-unix/oils/blob/master/doc/j8-notation.md A simple example demonstrating the structure of Tab-Separated Values (TSV) with a header row and data rows. ```text name age alice 44 bob 33 ``` -------------------------------- ### YSH String Examples Source: https://github.com/oils-for-unix/oils/blob/master/doc/j8-notation.md Examples of using u'' and b'' strings in YSH, highlighting their validity as code. ```text echo u'hi \u{1f642}' # u respected in YSH, but not OSH var myBytes = b'\yff\yfe' ```