Syntax brainstorming

The goal is for forky to have shell syntax with all the features of your favorite terminal. However, the nature of IRC prevents some challenges, for example:

  1. Not everything people say is meant for him to interpret
  2. The are other b0ts, and forkb0t needs to not stray into thier turf
  3. forkb0t should not use the same syntax as posix shells, because
    1. Some of his commands are processed through bash, and we don't want to risk cross-confuzzlement
    2. Some people (especially krushia) have brain farts and confuse terminal window with irc
  4. All i/o has to be nicely wrapped in raw IRC strings, and all input must pass through various IRC client preprocessing
  5. There is no way to know where strings are wrapped on everyone's screen
  6. People will often use different text encodings
  7. Ordered List Item

IF YOU HAVE SUGGESTIONS FOR SYNTAX, PLEASE ADD IT DOWN THERE IN THE NEEDED SECTION

Currently there are three special operators

>>>

"!command »> user" produces "user: output"

Why

"»>" is a derivative of shell file redirectors ">" and "»". "»>" acts as a redirector in forkb0t's code. DO NOT THINK OF IT AS A PREFIXER. When forkb0t runs a commandline, he "redirects" the output to a user in the channel. Without "»>", he will "redirect" to whoever ran the command (there are some exceptions, such as multiline spam.

>>>>

"!command »» channel" pipes output to channel

Why

"»»" was chosen because this is a "greater form of redirection" than "»>". When forkb0t runs a command line, he must indicate in the raw PRIVMSG IRC string as to where the output is going. Without "»»", he will use the channel in which the user ran the command.

<!

"!command1 <!command2" executes command2 and passes output as arguments to command1

Why

Initially this was supposed to be a copy of the pipe (|) from sh. However, forkb0t's commands have no concept of "stdin". They only have arguments. Hence the pipe effort was reduced to "piping as arguments". Note that "<!" is a bit of a misnomer. Since all of forkb0t's commands currently begin with !. Now we have this funky syntax that is hard to understand unless you know how the code works. Here are some comparisons to help.

forkb0t:
!cowsay <!forksay panda

shell:
cowsay $(forksay panda)


forkb0t:
!cowsay <!gtrans en2de <!wiki buttsecks

shell:
cowsay $(gtrans en2de $(wiki buttsecks))

As you can see, essentially <! is a nesting operator. If "stdin" and "arguments" were the same in your sh, then the shell pipe (|) would do the same thing but in reverse (if this makes sense).

Operators we need

Copy of | (pipe)

Well, "<!" really takes care of this already, except that the order is reversed, which makes it a bit confusing.

Copy of $() (command substitution)

perhaps !()

Concatenation

!forksay is the forkb0t equivalent of cat, and if command substitution is implemented then technically there is no need for a special operator for string joining. Although it may be simpler to implement something like "!+" than command substitution.

<krushia>!dict panda !+ | <!wiki panda
<forkb0t> krushia: panda -  1. large black-and-white Chinese mammal | "The Giant Panda (Ailuropoda melanoleuca, literally meaning 'cat-foot black-and-white') is a bear native to central-western and southwestern China." - http://en.wikipedia.org/wiki/Panda

idk, kinda nasty

Name prefix disabler

Currently if you don't want the name prefixed, you can do "!forksay <!command" because !forksay doesn't prefix by default. Of course users don't figure this trick out easily, so a specific operator may be of benefit.

Escape sequences

Currently there is no way to pass characters, such as CR, to forkb0t.

forkb0t/crap.txt · Last modified: 2010/01/16 01:28 by krushia
Back to top
Valid CSS Driven by DokuWiki Recent changes RSS feed Valid XHTML 1.0