Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
grep command?
#1
So in the 2016 release, there is mention of the termOS command 'grep', but ingame, no trace of it can be found. Since not even the AI is bored enough to sift through 12+ ping replies to find a PDA-message, it would be rather useful that have.

Does it still work or is it bugged? Is there a reason that the grep command was removed? Can it restored (provided that it is working)?
Reply
#2
i think this is reasonable if we think up another acronym for grep as a whole regex parser is overkill. this grep would take 2 params, a string & a filename, and print lines in that file that contain the string exactly like grep just without metacharacters.

i grepped for grep:

Code:
esmeralda:code kremlin$ pwd
/Users/kremlin/code/goonstation-2016/code
esmeralda:code kremlin$ find . -name '*.dm' | xargs grep grep
./obj/item/device/pda2/pda2.dm:                 var/datum/signal/pingreply = new
./obj/item/device/pda2/pda2.dm:                 pingreply.source = src
./obj/item/device/pda2/pda2.dm:                 pingreply.data["device"] = "NET_PDA_51XX"
./obj/item/device/pda2/pda2.dm:                 pingreply.data["netid"] = src.net_id
./obj/item/device/pda2/pda2.dm:                 pingreply.data["address_1"] = signal.data["sender"]
./obj/item/device/pda2/pda2.dm:                 pingreply.data["command"] = "ping_reply"
./obj/item/device/pda2/pda2.dm:                 pingreply.data["data"] = src.owner
./obj/item/device/pda2/pda2.dm:                         src.post_signal(pingreply)
./obj/machinery/vending.dm:             product_list += new/datum/data/vending_product("/obj/item/mechanics/regreplace", 30)
./WorkInProgress/MechanicMadness.dm:/obj/item/mechanics/regreplace
./WorkInProgress/MechanicMadness.dm:    icon_state = "comp_regrep"
./WorkInProgress/MechanicMadness.dm:            icon_state = "[under_floor ? "u":""]comp_regrep"
./WorkInProgress/computer3/mainframe2/utilities.dm://grep        Regexes and stuff.  idk.  nerds
./WorkInProgress/computer3/mainframe2/utilities.dm:/datum/computer/file/mainframe_program/utility/grep
./WorkInProgress/computer3/mainframe2/utilities.dm:     name = "grep"
./WorkInProgress/computer3/mainframe2/tapes.dm:         //newfolder.add_file( new /datum/computer/file/mainframe_program/utility/grep(src) )
./WorkInProgress/computer3/mainframe2/tapes.dm:         //src.root.add_file( new /datum/computer/file/mainframe_program/utility/grep(src) )
Reply
#3
(01-20-2018, 11:46 AM)kremlin Wrote: a list of .dm files.
I don't really know what that means.

I do know this:
https://github.com/goonstation/goonstati...es.dm#L786

So there is a bunch of code already there. The comments even mention arguments. The dir-structure says 'Work In Progress', but everything else in that file seems to be functioning just fine; I could not find duplicates of those other commands, and in-game they all function.
Reply
#4
it's every instance of the term "grep" in the codebase. the first field is the path of the file containing the term and the right is actual line it appaers on

there are some false positives like pingreply:

./obj/item/device/pda2/pda2.dm: pingreply.data["device"] = "NET_PDA_51XX"

whoops i shoulda taken a closer look heh.

ignore the WIP directory, there is a lot of currently used stuff sitting in it. it sorta needs cleaning up

there seems to be DM regular expression libraries available which would be a better solution than trying to write our own which is the approach taken in the code you linked. i would be against importing such a library as i don't think there's a good enough reason to warrant all that weight. printing lines that contain a match string is good enough for 99.999% of players
Reply
#5
(01-20-2018, 01:29 PM)kremlin Wrote: ignore the WIP directory
NEVA!!!!
(01-20-2018, 01:29 PM)kremlin Wrote: printing lines that contain a match string is good enough for 99.999% of players
I concur.


So after some testing, it seems the grep command works fine for '/datum/computer/file/record' and neatly prints out all the lines containing the matching string.
If you try it on a file that isn't record, the game slows to a crawl, which would explain why this isn't in-game at the moment. Adding an additional break-point stops that from happening.
The code makes no mention of a response for 'directory'.
But we will see about that.
Reply
#6
So, I am making some progress getting grep to work, but there is a section of code that defies my understanding.
https://github.com/goonstation/goonstati...es.dm#L855
The 'else'-block here is the other half of the ''if file-to-check is a record" statement, so it's supposed to scope out all other filetypes.
But it doesn't work for folders, and there are no readable files that aren't records. It sure as hell doesn't work for programs. The loop is incomplete and me adding an exit doesn't really help clear things up.

Is there any hope of contacting the person who wrote it?
Reply
#7
(01-21-2018, 09:30 AM)The Grim Sleeper Wrote: So, I am making some progress getting grep to work, but there is a section of code that defies my understanding.
https://github.com/goonstation/goonstati...es.dm#L855
The 'else'-block here is the other half of the ''if file-to-check is a record" statement, so it's supposed to scope out all other filetypes.
But it doesn't work for folders, and there are no readable files that aren't records. It sure as hell doesn't work for programs. The loop is incomplete and me adding an exit doesn't really help clear things up.

Is there any hope of contacting the person who wrote it?

instead of that just find me in discord or irc and i'll help figure it out (not today, perhaps tomorrow)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)