annotate paste/paste.14186 @ 10305:503b67656c89
<shachaf> ` >bin/edit echo \'#!/usr/bin/env python\'; >>bin/edit echo \'import sys, urllib\'; >>bin/edit echo \'print "http://slbkbs.org:5196/edit?path=" + urllib.quote(sys.argv[1])\'; chmod +x bin/edit
author |
HackBot |
date |
Fri, 17 Feb 2017 04:29:20 +0000 |
parents |
e037173e0012 |
children |
|
rev |
line source |
0
|
1 import System.Environment
|
|
2 import System.Process
|
|
3 import System.Exit
|
|
4 import Control.Monad
|
|
5 import Control.Applicative
|
|
6 import Data.List
|
|
7
|
|
8 main = do
|
|
9 r <- buildRegex . permuteArgs <$> getArgs
|
|
10 (_, _, _, h) <- createProcess (proc "/hackenv/bin/log" [r])
|
|
11 exitWith <$> waitForProcess h
|
|
12 where
|
|
13 permuteArgs = permutations . join . map words
|
|
14 buildRegex = oBrackets . intercalate ".*" . map (iBrackets . intercalate "|")
|
|
15 iBrackets s = "(?:" ++ s ++ ")"
|
|
16 oBrackets s = "^.*(?:" ++ s ++ ").*$"
|