« first day (2330 days earlier)      last day (2607 days later) » 

12:51 AM
Can you instrument a VM from the host?
 
 
11 hours later…
11:50 AM
If anyone's interested, a very useful shell function that I'm using several times a day when answering questions here on U&L: gist.github.com/kusalananda/c9c1c8590c5afde11c0333c51874e5b5
 
12:24 PM
@Kusalananda Nice! Shame about that vim fetish you have though.
> # vim: ft=sh
At least you recognize it for what it is. There's hope yet!
 
@terdon The first step of recovery is acceptance, they say.
 
:P
 
@Kusalananda I think that is for AA.
 
@terdon I'm too old to change by now. I'm clinging on to Vi/Vim for mostly nostalgic reasons, and for the fact that it's ubiquitous on the systems I'm working with. Motoric memory is hard to reprogram, too.
@FaheemMitha Automobile Association?
 
@Kusalananda It helps that it's a great editor.
Although I'll deny having ever said that.
 
12:29 PM
@terdon Your secret is safe with me.
 
I've learned the basic i, :w, :wq and :!q commands and that's about all I know how to do in vi. Enough to run visudo once, install emacs and set it as the default editor.
 
@terdon Goes without saying that you're in Emacs editing mode in the shell too, I suppose? :-)
 
Why, is there any other? ;)
 
:-) I'm being repressed!
 
Although I just told my boss, a long time vi user, that there's a vi mode in the shell and he had no idea!
@Kusalananda Hardly, I think the only emacs people here are Gilles (who also speaks vim, naturally) and myself. Maybe slm, but I don't remember.
most of the rest of you crazies are vimists.
 
12:33 PM
Vimimalists
 
:)
 
I tried using bash as my primary shell for a while, but its vi-mode didn't suit me, so I stayed with ksh93. The GNU dev crowd seems to focus on Emacs when it comes to capabilities (in Readline). I can't point to anything specific ATM, except that it's impossible to change it so that you're in normal (command) mode by default.
... or at the beginning of the command line rather than at the end.
 
Huh. Dunno, I've never tried vi mode, obviously. But that sounds like a pain.
 
@Kusalananda Alcoholics Anonymous.
 
@FaheemMitha Ah, I should have guessed. The 12 steps programme.
 
12:41 PM
@terdon I use emacs too.
Though not a power user. I know a few commands.
 
Nowadays, nano and emacs just confuses me.
 
Emacs has a zillion commands. I'm surprised anyone could remember more than a few. Often I look them up when I need them, then forget them again.
 
I tried viper in emacs once. Then I really felt like a recovering alcoholic!
 
viper? Some sort of vim mode for emacs?
There's also spacemacs which seems to be quite good.
 
@terdon You've not heard of it? Even I have. Though I haven't used it, of course. Seeing as I don't know vi at all.
 
12:49 PM
@FaheemMitha You're emacs too?
And no, I haven't.
> Besides being the newest variety of vi emulation, it also provides users different levels of emulation to help vi addicts kick the habit.
heh
 
8 mins ago, by Faheem Mitha
@terdon I use emacs too.
@terdon ^^
 
Sorry! Missed that.
I always knew you were a reasonable fellow.
 
I can't really call myself an emacs user. I don't know enough.
Fortunately emacs has a low entry threshold.
 
@terdon Exactly that.
@FaheemMitha Ah that's GNU for you. Gives you just enough rope to shoot yourself in the foot with. Eh, you know what I mean.
Where I live, I overlook a bird sanctuary, a wetland reserve. It used to be farmland. I can see a a flock of swans coming in for landing.
Spring is on the way I think.
Anyways... with that shell function, just say shell to start up a new temporary shell, or shell bash or shell zsh or whatever if you need to test anything in those shells. Handy.
 
Yep
Although I usually just have a ~/foo directory for this sort of crap.
 
1:02 PM
Saves in cleaning up afterwards and you don't need to cd elsewhere...
 
But creating/deleting on the fly and getting a clean shell is a useful trick
Here's one I often use when testing portability:
$ type checkshell
checkshell is a function
checkshell ()
{
    grep --color -Po '^[^#].*/\K.+' /etc/shells | sort -u | while read s; do
        echo -en "${s##*/}\t:   ";
        $s -c "$@";
    done
}
And this to time different commands:
$ type timethis
timethis is a function
timethis ()
{
    max=$1;
    shift;
    for com in "$@";
    do
        echo "COMMAND: $com ";
        c=0;
        while [[ $c -lt $max ]]; do
            echo $c 1>&2;
            let c++;
            ( time -p eval "$com" ) 2>&1 | grep --color -oP 'real.*?\K[\d\.]+';
        done | awk -vm=$max '{k+=$1}END{print (k/m)}';
    done
}
 
First one is useful for testing a command is different shells, yes. Requires GNU grep though ;-)
And echo -e? Really? Oh well, each to his own.
 
@Kusalananda Give me a break, it's old! :)
 
:-) it's fine
 
@Kusalananda Pictures! Pictures!
You have a much better view than I do. From where I sit, I can see wall. White, mostly. And not very interesting.
 
1:12 PM
Here, POSIX version ;)
checkshell(){

    awk -F"/" '!/^#/ && NF>1{print $NF}' /etc/shells | sort | uniq |
				while read s ; do
						printf '%s' "${s##*/}\t:   ";
						"$s" -c "$@";
				done
}
sort -u is also GNU, right?
 
@FaheemMitha They're gone now. Here's a view from the "office" (kitchen) from last year on a misty day (too lazy to take a new photo right now): instagram.com/p/BCpkHePE6B3
@terdon No, it's in POSIX.
 
Oh, huh. I always thought that was a gnuism.
 
Nope, isn't.
 
Yep, just checked. Nice!
 
@terdon I'll add something similar to my collection. Thanks for sharing!
 
1:22 PM
@Kusalananda You're very welcome and please share back if you improve it. It could report failed commands much better than it does.
 
2:19 PM
@Kusalananda Something with less white would be nice.
 
2:38 PM
@FaheemMitha It was, and is, winter...
 
@Kusalananda All that white must get monotonous.
 
Yes.
 
They really should manufacture snow in multiple colours. It would make things more interesting.
 
@terdon I had a friend who liked Frank Zappa. Haven't talked to him in awhile.
 
2:44 PM
One of the most brilliant musicians of the 20th century.
Or, more likely "minds" in general. The man was a genius.
 
@terdon Oh. I'm not familiar with his work.
 
Frank Vincent Zappa (December 21, 1940 – December 4, 1993) was an American musician, composer, songwriter, producer, guitarist, actor, and filmmaker whose work was characterized by nonconformity, free-form improvisation, sound experiments, musical virtuosity, and satire of American culture. In a career spanning more than 30 years, Zappa composed rock, pop, jazz, jazz fusion, orchestral and musique concrète works, and produced almost all of the 60-plus albums that he released with his band the Mothers of Invention and as a solo artist. Zappa also directed feature-length films and music videos, and...
Incredibly versatile artist.
And holy crap can he play!
 
@terdon I made something.
function testthis
{
    # Will run the given command in all avaliable shells and capture and
    # display the output generated on standard output as well as any
    # diagnostic messages generated on standard error, together with the
    # exit code.

    grep '^[^#]' /etc/shells | (
    typeset -a tmpfiles
    trap 'rm -f "${tmpfiles[@]}"' EXIT
    while read realshell; do
        typeset shell="${realshell##*/}"

        typeset tmpout="$( mktemp -p /tmp "$shell-out.XXXXXXXX" )"
        typeset tmperr="$( mktemp -p /tmp "$shell-err.XXXXXXXX" )"
 
Nice!
 $ testthis 'wc <(echo foo)'
=== sh (exit 1)
--- stdout:
--- stderr:
/bin/sh: -c: line 0: syntax error near unexpected token `('
/bin/sh: -c: line 0: `wc <(echo foo)'
=== bash (exit 0)
--- stdout:
      1       1       4 /dev/fd/63
--- stderr:
 
Yay
$ testthis 'wc <(echo foo)'
=== sh (exit 1)
--- stdout:
--- stderr:
/bin/sh: syntax error: `(' unexpected
=== csh (exit 1)
--- stdout:
--- stderr:
Missing name for redirect.
=== ksh (exit 1)
--- stdout:
--- stderr:
/bin/ksh: syntax error: `(' unexpected
=== ksh93 (exit 0)
--- stdout:
       1       1       4 /dev/fd/3
--- stderr:
=== rksh93 (exit 0)
--- stdout:
       1       1       4 /dev/fd/3
--- stderr:
=== bash (exit 0)
--- stdout:
       1       1       4 /dev/fd/63
--- stderr:
=== dash (exit 2)
 
3:00 PM
Which reminds me. I need to install some shells on my new machine.
 
My sh/ksh is pdksh.
 
3:12 PM
I just realized that the EXIT trap in bash isn't caught on function return as in ksh93. Bash has a RETURN trap for that. I'v updated my "shell" function for that: gist.github.com/kusalananda/c9c1c8590c5afde11c0333c51874e5b5 Also, that thest function is on gist now too: gist.github.com/kusalananda/1981b54a148db161ec166409ad22d599
Need to do some work now...
 

« first day (2330 days earlier)      last day (2607 days later) »