3 Short Talks, NYC*BUG, 2016.02.03 Isaac (.Ike) Levy
Total Page:16
File Type:pdf, Size:1020Kb
shell-fu 3 short talks, NYC*BUG, 2016.02.03 Isaac (.ike) Levy <[email protected]> disclaimer The views expressed in this presentation are my own and do not represent the views of my current or former employers, nor do they represent the *BSD projects, or NYC*BUG as a whole. No animals were harmed in the making of this presentation. community sidenote standing strong against ongoing abuse and harassment 3 short talks the 3 finger claw technique using atomic filesystem operations general shell-fu, (input and variable handling) shell-fu 3 short talks, NYC*BUG, 2016.02.03 Isaac (.ike) Levy <[email protected]> ber ike web bub matt ken dmr bwk djb doug ken dmr First with UNIX (the first unix shell) https://www.youtube.com/watch?v=tc4ROCJYbm0 AT&T Archives: The UNIX Operating System ken SRB, NYC*BUG 2015.11.19 http://www.nycbug.org/event/10636/ NYCBug.20151119.srb.pdf https://www.bell-labs.com/usr/dmr/www/ retro.pdf 1975, Ken Thompson was in Berkeley for a year "In 1975, Thompson took a sabbatical from Bell Labs and went to his alma mater, UC Berkeley. There, he helped to install Version 6 Unix on a PDP-11/70. Unix at Berkeley would later become maintained as its own system, known as the Berkeley Software Distribution (BSD)." ken mckusick joy beastie by 1982, TCP/IP, UFS, etc... 2012 1976, Ken Thompson returned to Murray Hill ~ 1976, the bourne shell not the right bourne srb 1969 1970 1971 1972 1973 http://www.levenez.com/unix UNIX Time-Sharing System UNIX Time-Sharing System UNIX Time-Sharing System UNICS First Edition (V1) Second Edition (V2) Third Edition (V3) september 1969 november 3, 1971 june 12, 1972 february 1973 Open Systems November 28, 2015 Éric Lévénez 1998-2015 <http://www.levenez.com/unix/> 1974 1975 1976 1977 http://www.levenez.com/unix SRI Eunice UNSW Mini Unix may 1977 LSX UNIX Time-Sharing System UNIX Time-Sharing System UNIX Time-Sharing System Fourth Edition (V4) Fifth Edition (V5) Sixth Edition (V6) november 1973 june 1974 may 1975 PWB/UNIX PWB 1.0 1974 july 1, 1977 USG 1.0 TS 1.0 1977 MERT 1974 RT 1.0 1977 1974 1975 1976 1977 http://www.levenez.com/unix SRI Eunice UNSW Mini Unix may 1977 LSX UNIX Time-Sharing System UNIX Time-Sharing System UNIX Time-Sharing System Fourth Edition (V4) Fifth Edition (V5) Sixth Edition (V6) november 1973 june 1974 may 1975 PWB/UNIX PWB 1.0 1974 july 1, 1977 USG 1.0 TS 1.0 1977 MERT 1974 RT 1.0 1977 ~ 1976, the bourne shell sh sh tcsh Thompson Shell PWB Mashey Shell T C shell Ken Thompson John Mashey Bill Joy 1969 1975 1978 reaction reaction dash sh ash Debian Almquist bourne shell Almquist Debian Linux Steven Bourne Kenneth Almquist 2011 1976 ~1989 bash sh ksh Gnu Bourne Again sh FreeBSD sh Korn shell Brian Fox Debian Linux David Korn 1989 ~1994 1983 sh ksh88 POSIX Shell Korn shell POSIX POSIX 1992 pkdsh 1988 Public Domain Korn OpenBSD ksh88 1999 Korn shell POSIX ksh93 1988 Korn shell rc Linux Distros Plan9, UNIX v10 1994? Tom Duff 1989 zsh Z Shell Paul Falstad 1990 sh sh tcsh Thompson Shell PWB Mashey Shell T C shell Ken Thompson John Mashey Bill Joy 1969 1975 1978 reaction reaction dash sh ash Debian Almquist bourne shell Almquist Debian Linux Steven Bourne Kenneth Almquist 2011 1976 ~1989 bash sh ksh Gnu Bourne Again sh FreeBSD sh Korn shell Brian Fox Debian Linux David Korn 1989 ~1994 1983 sh ksh88 POSIX Shell Korn shell POSIX POSIX 1992 pkdsh 1988 Public Domain Korn OpenBSD ksh88 1999 Korn shell POSIX ksh93 1988 Korn shell rc Linux Distros Plan9, UNIX v10 1994? Tom Duff 1989 zsh Z Shell Paul Falstad 1990 sh sh tcsh Thompson Shell PWB Mashey Shell T C shell Ken Thompson John Mashey Bill Joy 1969 1975 1978 reaction reaction dash sh ash Debian Almquist bourne shell Almquist Debian Linux Steven Bourne Kenneth Almquist 2011 1976 ~1989 bash sh ksh Gnu Bourne Again sh FreeBSD sh Korn shell Brian Fox Debian Linux David Korn 1989 ~1994 1983 sh ksh88 POSIX Shell Korn shell POSIX POSIX 1992 pkdsh 1988 Public Domain Korn OpenBSD ksh88 1999 Korn shell POSIX ksh93 1988 Korn shell rc Linux Distros Plan9, UNIX v10 1994? Tom Duff 1989 zsh Z Shell Paul Falstad 1990 wacky observations... sh sh tcsh Thompson Shell PWB Mashey Shell T C shell Ken Thompson John Mashey Bill Joy 1969 1975 1978 reaction reaction dash sh ash Debian Almquist bourne shell Almquist Debian Linux Steven Bourne Kenneth Almquist 2011 1976 ~1989 bash sh ksh Gnu Bourne Again sh FreeBSD sh Korn shell Brian Fox Debian Linux David Korn 1989 ~1994 1983 sh srb! ksh88 POSIX Shell Korn shell POSIX POSIX 1992 pkdsh 1988 Public Domain Korn OpenBSD ksh88 1999 Algol68 Korn shell Language POSIX ksh93 Stephen Bourne 1988 Korn shell 1968 rc Linux Distros Plan9, UNIX v10 1994? Tom Duff ABC Language 1989 Z Shell zsh Paul Falstad Z Shell 1990 Paul Falstad 1990 Python Language Guido van Rossum 1989 sh sh tcsh Thompson Shell PWB Mashey Shell T C shell Ken Thompson John Mashey Bill Joy 1969 1975 1978 reaction reaction dash sh ash Debian Almquist bourne shell Almquist Debian Linux Steven Bourne Kenneth Almquist 2011 1976 ~1989 bash sh ksh Gnu Bourne Again sh FreeBSD sh Korn shell Brian Fox Debian Linux David Korn 1989 ~1994 1983 sh srb! ksh88 POSIX Shell Korn shell POSIX POSIX 1992 pkdsh 1988 Public Domain Korn OpenBSD ksh88 1999 Algol68 Korn shell Language POSIX ksh93 Stephen Bourne 1988 Korn shell 1968 rc Linux Distros Plan9, UNIX v10 1994? Tom Duff ABC Language 1989 Z Shell zsh Paul Falstad Z Shell 1990 Paul Falstad 1990 Python Language Guido van Rossum 1989 sh sh tcsh Thompson Shell PWB Mashey Shell T C shell Ken Thompson John Mashey Bill Joy 1969 1975 1978 reaction reaction dash sh ash Debian Almquist bourne shell Almquist Debian Linux Steven Bourne Kenneth Almquist 2011 1976 ~1989 bash sh ksh Gnu Bourne Again sh FreeBSD sh Korn shell Brian Fox Debian Linux David Korn 1989 ~1994 1983 sh srb! ksh88 POSIX Shell Korn shell POSIX POSIX 1992 pkdsh 1988 Public Domain Korn OpenBSD ksh88 1999 Algol68 Korn shell Language POSIX ksh93 Stephen Bourne 1988 Korn shell 1968 rc Linux Distros Plan9, UNIX v10 1994? Tom Duff ABC Language 1989 Z Shell zsh Paul Falstad Z Shell 1990 Paul Falstad 1990 Python Language Guido van Rossum 1989 people start agreeing on data type primitives sh sh tcsh Thompson Shell PWB Mashey Shell T C shell Ken Thompson John Mashey Bill Joy 1969 1975 1978 reaction reaction dash bourneish sh ash Debian Almquist bourne shell Almquist Debian Linux Steven Bourne Kenneth Almquist 2011 1976 ~1989 bash sh ksh Gnu Bourne Again sh FreeBSD sh Korn shell Brian Fox Debian Linux David Korn 1989 ~1994 1983 sh srb! ksh88 POSIX Shell Korn shell POSIX POSIX 1992 pkdsh 1988 Public Domain Korn OpenBSD ksh88 1999 Algol68 Korn shell Language POSIX ksh93 Stephen Bourne 1988 Korn shell 1968 rc Linux Distros Plan9, UNIX v10 1994? Tom Duff ABC Language 1989 Z Shell zsh Paul Falstad Z Shell 1990 Paul Falstad 1990 Python Language Guido van Rossum 1989 people start agreeing on data type primitives sh sh tcsh Thompson Shell PWB Mashey Shell T C shell Ken Thompson John Mashey Bill Joy 1969 1975 1978 reaction reaction dash sh ash Debian Almquist bourne shell Almquist Debian Linux Steven Bourne Kenneth Almquist 2011 1976 ~1989 bash sh ksh Gnu Bourne Again sh FreeBSD sh Korn shell Brian Fox Debian Linux David Korn 1989 ~1994 1983 sh ksh88 POSIX Shell Korn shell POSIX POSIX 1992 pkdsh 1988 Public Domain Korn OpenBSD ksh88 1999 Korn shell POSIX ksh93 1988 Korn shell rc Linux Distros Plan9, UNIX v10 1994? Tom Duff 1989 zsh Z Shell portability Paul Falstad 1990 3 short talks the 3 finger claw technique using atomic filesystem operations general shell-fu, (input and variable handling) the 3 finger claw technique existential functions Pai Mei White Lotus Clan, Shaolin Legendary 5 Elders, Kill Bill, Wu Tang Clan, etc... yell() { echo "$0: $*" >&2; } die() { yell "$*"; exit 111; } try() { "$@" || die "cannot $*"; } shout() { echo "$0: $*" >&2; } barf() { shout "$*"; exit 100; } safe() { "$@" || barf "cannot $*"; } original yell() { echo "$0: $*" >&2; } die() { yell "$*"; exit 111; } try() { "$@" || die "cannot $*"; } #!/bin/sh yell() { echo "$0: $*" >&2; } die() { yell "$*"; exit 111; } try() { "$@" || die "cannot $*"; } # using it try cd /some/place try tar xzvfp /elsewhere/stuff.tbz true the 3 finger claw technique, 3 short functions #!/bin/sh cd /some/place tar xzvfp /elsewhere/stuff.tbz #!/bin/sh cd /some/place tar xzvfp /elsewhere/stuff.tbz (a terrible program, stick that in cron?!) #!/bin/sh yell() { echo "$0: $*" >&2; } die() { yell "$*"; exit 111; } try() { "$@" || die "cannot $*"; } # using it try cd /some/place try tar xzvfp /elsewhere/stuff.tbz true #!/bin/sh yell() { echo "$0: $*" >&2; } die() { yell "$*"; exit 111; } try() { "$@" || die "cannot $*"; } # using it try cd /some/place try tar xzvfp /elsewhere/stuff.tbz true #!/bin/sh yell() { echo "$0: $*" >&2; } die() { yell "$*"; exit 111; } try() { "$@" || die "cannot $*"; } # using it try cd /some/place try tar xzvfp /elsewhere/stuff.tbz true #!/bin/sh yell() { echo "$0: $*" >&2; } die() { yell "$*"; exit 111; } try() { "$@" || die "cannot $*"; } # using it try cd /some/place try tar xzvfp /elsewhere/stuff.tbz true #!/bin/sh yell() { echo "$0: $*" >&2; } die() { yell "$*"; exit 111; } try() { "$@" || die "cannot $*"; } # using it try cd /some/place try tar xzvfp /elsewhere/stuff.tbz true #!/bin/sh yell() { echo "$0: $*" >&2; } die() { yell "$*"; exit 111; } try() { "$@" || die "cannot $*"; } # using it try cd /some/place try tar xzvfp /elsewhere/stuff.tbz true #!/bin/sh yell() { echo "$0: $*" >&2; } die() { yell "$*"; exit 111; } try() { "$@" || die "cannot $*"; } # using it try cd /some/place