Ben Chuanlong Du's Blog

It is never too late to learn.

Shell in Docker

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

Configure the Shell for the RUN Command

https://docs.docker.com/engine/reference/builder/#shell

Configure the Default Shell for Terminals in Docker Containers

Just set the SHELL environment variable in …

Tips on Xonsh

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

https://github.com/xonsh/xonsh/wiki/Cheatsheet

Tricks and Traps

  1. While $() in xonsh works similar to $() in (all variants of) shell, it cannot be used in the middle of argument of …

Calling Shell from Python

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

  1. subprocess.run is preferred to the function os.system for invoking shell commands. For more discussions, pleaser refer to [Hands on the Python module subprocess]https://www.legendu.net/en/blog …

Parallel Computing in Shell

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

  1. & and wait

  2. parallel

  3. xargs

parallel is a cool bash command which makes parallel computing easy in Bash. It is a parallel version replacement of xargs.

Preferred Python Version in Shebang

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

#!/bin/sh
''''which python2 >/dev/null 2>&1 && exec python2 "$0" "$@" # '''
''''which python  >/dev/null 2>&1 && exec python  "$0" "$@" # '''
''''exec echo "Error: I can't find python anywhere"         # '''

Reference

https …