Batch renaming images, including image resolution, with awk
> I previously wrote about the power of command line tools like sed. This post expands on how to string all this magical functionality into one big, long, rainbow-coloured, viscous stream of awesome.
> Today, we’re introducing a new shell, written in Rust. It draws inspiration from the classic Unix philosophy of pipelines, the structured data approach of PowerShell, functional programming, systems programming, and more.
A one liner to rename files.
> ls | grep ‘aaa’ | sed ‘p;s/aaa/bbb/’ | xargs -n2 | xargs -L1 bash -c ‘mv $0 $1’
shebangs and busybox
> neat, right? this lets us write shell scripts that are portable across all sorts of different setups. except there’s a problem.
Tricking the tricksters with a next level fork bomb
> Some people make a cruel sport out of tricking newbies into running destructive shell commands.
> Years ago, I came across someone doing this, and decided to trick them back.
How Bash decides it's being invoked through sshd and sources your .bashrc
> In practice, a non-interactive Bash decides that it is being invoked by SSHD if either $SSH_CLIENT or $SSH2_CLIENT are defined in the environment. In a robotic sense this is perfectly correct, since OpenSSH’s sshd puts $SSH_CLIENT in the environment when you do ‘ssh host command’. In practice it is wrong, because OpenSSH sets $SSH_CLIENT all the time, including for logins. So if you use SSH to log in somewhere, $SSH_CLIENT will be set in your shell environment, and then any non-interactive Bash will decide that it should source ~/.bashrc.
This seems incredibly messy.
goto - command transfer
> Goto is allowed only when the Shell is taking commands from a file. The file is searched from the beginning for a line beginning with `:’ followed by one or more spaces followed by the label. If such a line is found, the goto command returns. Since the read pointer in the command file points to the line after the label, the effect is to cause the Shell to transfer to the labelled line.
kitty - the fast, featureful, GPU based terminal emulator
> kitty is designed for power keyboard users. To that end all its controls work with the keyboard (although it fully supports mouse interactions as well). Its configuration is a simple, human editable, single file for easy reproducibility (I like to store configuration in source control).
> The code in kitty is designed to be simple, modular and hackable. It is written in a mix of C (for performance sensitive parts) and Python (for easy hackability of the UI). It does not depend on any large and complex UI toolkit, using only OpenGL for rendering everything.
> Finally, kitty is designed from the ground up to support all modern terminal features, such as unicode, true color, bold/italic fonts, text formatting, etc. It even extends existing text formatting escape codes, to add support for features not available elsewhere, such as colored and styled (curly) underlines. One of the design goals of kitty is to be easily extensible so that new features can be added in the future with relatively less effort.
> fish 3 is a major release, which introduces some breaking changes alongside improved functionality. Although most existing scripts will continue to work, they should be reviewed against the list contained below.
A Survey of $RANDOM
> Most Bourne shell clones support a special RANDOM environment variable that evaluates to a random value between 0 and 32,767 (e.g. 15 bits). Assigment to the variable seeds the generator. This variable is an extension and did not appear in the original Unix Bourne shell. Despite this, the different Bourne-like shells that implement it have converged to the same interface, but only the interface. Each implementation differs in interesting ways. In this article we’ll explore how $RANDOM is implemented in various Bourne-like shells.
Subprocesses are generally bad news
> “Shelling out” to something else is a fantastic way to open incredibly bad holes in your system and potentially give the entire game away to whoever happens to find it first.
Why Create a New Unix Shell?
> Whenever I announce a new Oil release, some readers are confused by the project. This post, which I’ll update periodically, explains the project’s motivation from several perspectives. Because Unix shell is an old and successful technology, there are many ways of looking at it.
Ten Things I Wish I’d Known About bash
> You don’t have to look hard on the internet to find plenty of useful one-liners in bash, or scripts. And there are guides to bash that seem somewhat intimidating through either their thoroughness or their focus on esoteric detail. Here I’ve focussed on the things that either confused me or increased my power and productivity in bash significantly, and tried to communicate them (as in my book) in a way that emphasises getting the understanding right.
Integrated development window manager
> There is an integrated development window manager where you can: Select any compiler error text in any terminal and open the correct file and line in your text editor. Click on the output of ls in any terminal and open the corresponding file with the correct program. Click any url from any text on your OS and open it in your browser. What if I told you it is actually just a 100 line shell script?
Problems With the test Builtin: What Does -a Mean?
To [ -a ] or to [ -a -a ].
Compromise On Checkout - Vulnerabilities in SCM Tools
The redirection can come anywhere on the line, so watch out for those spaces
Tab completion in OpenBSD's ksh
> One of the features OpenBSD’s ksh shares with its more popular friends is user definable completions!
Something you didn't know about functions in bash
Writing functions without braces.