Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Perl で作る tiny shell

Perl で作る tiny shell

Perl で極限に機能を削った shell の作り方を紹介します

Kei Kamikawa

June 23, 2018
Tweet

More Decks by Kei Kamikawa

Other Decks in Programming

Transcript

  1. Ͳ͏͍͏ಈ࡞Λ͢Δ͔ w ୯ҰίϚϯυͷ࣮ߦ $ ls  w ύΠϓͷ࣮ߦ $ ls

    | cat  w ΞϯυʹΑΔෳ਺࣮ߦ $ ls && cat  w αϒγΣϧ΍όοΫάϥϯυ࣮ߦ͸ࠓճؚΊ·ͤΜ
  2. ߏจఆٛ • CMD: [a-zA-Z_-][0-9a-zA-Z_-]* <ARG> • ARG: [0-9a-zA-Z_-]* <ARG> |

    [0-9a-zA-Z_-]* • SHLL: <PIPE> '&&' <AND> | <PIPE> • PIPE: <CMD> '|' <PIPE> | <CMD> • AND: <SHLL> '&&' <AND> | <SHLL>
  3. ߏจఆٛ • CMD: [a-zA-Z_-][0-9a-zA-Z_-]* <ARG> • ARG: [0-9a-zA-Z_-]* <ARG> |

    [0-9a-zA-Z_-]* • SHLL: <PIPE> '&&' <AND> | <PIPE> • PIPE: <CMD> '|' <PIPE> | <CMD> • AND: <SHLL> '&&' <AND> | <SHLL>
  4. $.%

  5. ߏจఆٛ • CMD: [a-zA-Z_-][0-9a-zA-Z_-]* <ARG> • ARG: [0-9a-zA-Z_-]* <ARG> |

    [0-9a-zA-Z_-]* • SHLL: <PIPE> '&&' <AND> | <PIPE> • PIPE: <CMD> '|' <PIPE> | <CMD> • AND: <SHLL> '&&' <AND> | <SHLL>
  6. ߏจఆٛ • CMD: [a-zA-Z_-][0-9a-zA-Z_-]* <ARG> • ARG: [0-9a-zA-Z_-]* <ARG> |

    [0-9a-zA-Z_-]* • SHLL: <PIPE> '&&' <AND> | <PIPE> • PIPE: <CMD> '|' <PIPE> | <CMD> • AND: <SHLL> '&&' <AND> | <SHLL>
  7. ߏจఆٛ • CMD: [a-zA-Z_-][0-9a-zA-Z_-]* <ARG> • ARG: [0-9a-zA-Z_-]* <ARG> |

    [0-9a-zA-Z_-]* • SHLL: <PIPE> '&&' <AND> | <PIPE> • PIPE: <CMD> '|' <PIPE> | <CMD> • AND: <SHLL> '&&' <AND> | <SHLL>
  8. "/%

  9. "/% 1*1& DBU DBU MT $ cat | cat -n

    && ls ᶃ ᶄ ᶅ ᶆ ᶇ
  10. $ fortune | cowsay 45%*/ PS/PU 45%065 45%*/ 45%065 ᶃ

    ᶄ ᶅ ᶆ 8SJUFS 3FBEFS ᶇ ᶈ ᶉ