zentara has asked for the wisdom of the Perl Monks concerning the following question:

Update: See my reply below for a better explanation of what happened.

Hi, I inadvertently tried to execute a file named ?1. What surprised me was the output.

$ ?1 W5O!P%@AP[4\PZ 104 101 108 108 111 44 32 119 111 114 108 100 33 10 ºA
I guess I could make this a Perl question by executing it thru Perl IPC, but can someone help me make sense of what that output is? A bug ? Thanks.

I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh

Replies are listed 'Best First'.
Re: OT: a bash shell oddity, need explanation
by choroba (Cardinal) on Feb 07, 2014 at 13:19 UTC
    ? is a shell wildcard that stands for one character. There probably was a file called 11, 21, a1 b1, A1, or whatever, which was executed. If there were more files matching the pattern, the rest of them was used as parameters to the first one.
    لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
Re: OT: a bash shell oddity, need explanation
by no_slogan (Deacon) on Feb 07, 2014 at 13:31 UTC

    Interestingly,

    print chr for qw(104 101 108 108 111 44 32 119 111 114 108 100 33 10)

    results in hello, world!

      Thanks for that reminder. :-) After thinking about what you wrote, I did a "which ?1" as choroba indicated, and it found a file called z1, which contained the phrase "hello world". The question remains why the hex control characters remained in the shell. I believe roboticus is right about this, that the terminal's answerback setting got set by the Perl script, and it printed out z1 in binary or hex. Strange, but I understand now.

      I'm not really a human, but I play one on earth.
      Old Perl Programmer Haiku ................... flash japh
Re: OT: a bash shell oddity, need explanation
by zentara (Cardinal) on Feb 07, 2014 at 13:32 UTC
    Thanks choroba, but in trying to replicate the problem, I think some unwanted control characters got put into my shell.

    I was looking at Removing non-printing (hex codes) from text files and ran at the following code as an experiment:

    #!/usr/bin/perl $s .= chr for 1..255; print $s,"\n\n"; $s =~ tr/\x20-\x7f//cd; print $s,"\n\n";
    Only after running that code in a terminal, will the ?1 execution work as I describe. If that code is not run first, the ?1 acts normally, saying "file not found".

    So that opens a new question, how do those hidden control codes get saved for the next execution in that terminal?


    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku ................... flash japh

      zentara:

      A vt100 has an "answerback" string--you send an escape sequence to tell the terminal what to send you when you send the appropriate "inquiry" character. I don't know what terminal you're using, but it's possibly a similar mechanism.

      ...roboticus

      When your only tool is a hammer, all problems look like your thumb.

      IDK. Try it from within a bash -x and see what happens?