Hacker News new | past | comments | ask | show | jobs | submit login

Some examples of where one finds Dash (NetBSD-derived Almquist shell, or "ash") in Linux

   The git.kernel.org repository
   Slackware
   Debian 
   Unbuntu
   Gentoo
   Arch initramfs
   Alpine 
   Tiny Core 
   OpenWRT
   Any other distrib that uses Busybox
   Android
What the OP fails to mention is that this shell one-liner (cf. "Bash one-liner"), as written, requires GNU grep, thanks to "-P".

BusyBox grep does not have a "-P" option.

In the case of Android, Google uses NetBSD userland programs, e.g., grep, which also does not include PCRE, i.e., "-P".

https://coral.googlesource.com/android-core/+/3458bb6ce1d3e7...

https://git.kernel.org/pub/scm/utils/dash/dash.git/

   curl -O https://mirror.rackspace.com/archlinux/iso/2022.10.01/arch/boot/x86_64/initramfs-linux.img
   xz -dc < initramfs-linux.img|cpio -t|grep -m1 usr/bin/ash



It's written with `-P` but doesn't actually need it. Standard `-E` works just fine instead.


How many "professional" programmers even know the difference between BRE, ERE and PCRE.

Perhaps this is why use of regex is so controversial amongst a majority of "professional" programmers. They are trying to use PCRE for every pattern matching task, i.e, even ones where it is not necessary, whether it is within their programing language or with command-line utilities. This "Bash one-liner" is a simple example.

I have reviewed a number of books written about regular expressions and for the most part^1 they focus only on regex as implemented in popular programming languages. That almost invariably is PCRE or some form of PCRE-like pattern matching. There is little distinction, let alone acknowledgment, between PCRE/PCRE-like patterns and anything simpler.

Not being a "professional" programmer, I use regex everyday but I never (intentionally) use PCRE.^2 Too complicated for my tastes, not to mention slow if using backtracking.

1. I recall one older book that did include an incomplete table attempting to show which type of regex was used by various UNIX utilities in addition to what regex was used by popular programming languages of the day.

2. For programs that optionally link to a PCRE library, I re-compile without them without it.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: