@verb #13:"@grep*! @egrep*!" any on top of/on/onto/upon any rdo #789 @program #13:"@grep*! @egrep*!" any on top of/on/onto/upon any "@[e]grep*! on [objects|player]<.:!>" "Searches properties, verbs and files on the object(s) for the expression." "Expression is literal, unless @egrep is used in which case it is a regex." "Only lists the first match in each prop/verb/file, unless grep! is used." "Objects can be a range in the format of #123..#234 or #123-#234." "If just a player is specified, then their audit is included in the grep." "If no objects are specified, then the entire Moo is grepped." "" if (player != this) return $msg:mtell("huh") endif this:isa($guardian) || set_task_perms(player) all_matches = verb[$] == "!" is_regex = verb[2] == "e" m = match(iobjstr, "[.:!]*$") mode = iobjstr[m[1]..m[2]] objectstr = $su:trim(iobjstr[1..m[1] - 1]) if (!objectstr) "If no objects are specified, then the entire Moo is grepped." objects = $set_utils:union($root:descendants_suspended(), {$trash, $root, $new_root}) elseif (m = match(objectstr, "^%(#?[0-9]+%)%(-%|%.%.%)%(#?[0-9]+%)$")) "Objects can be a range in the format of #123..#234 or #123-#234." objects = {} for x in [toobj(m[$][m[3][1][1]..m[3][1][2]])..toobj(m[$][m[3][3][1]..m[3][3][2]])] $recycler:valid(x) && (objects = {@objects, x}) endfor else objects = {player:my_match_object(objectstr)} if ($command_utils:object_match_failed(objects[1], objectstr)) return elseif (objects[1]:isa($accountable)) "If just a player is specified, then their audit is included" objects = setadd(objects[1].owned_objects, objects[1]) endif endif syntax = "Syntax: @[e]grep*! <expression> on [objects|player]<.:!>" "Undo the damage caused by the XML munging system..." dobjstr = player:input_get_raw(dobjstr) if (!dobjstr) player:tell("No expression given.") player:tell(syntax) return elseif (!objects) player:tell("Zero objects specified.") player:tell(syntax) return elseif (is_regex && `match("test", dobjstr) ! E_INVARG' == E_INVARG) player:tell("'", $html_utils:literal_text(dobjstr), "' is not a legal regular expression.") player:tell(syntax) return elseif (!mode) player:tell("Grep what? Properties (.) Verbs (:) and/or Files (!)") player:tell(syntax) return endif $code_utils:semaphore_enter("grep") if (index(mode, ".")) this:tell("=== ", verb, " of properties on ", length(objects) == 1 ? $su:nn(objects[1]) | tostr(length(objects), " objects"), " for '", $html_utils:literal_text(dobjstr), "' ===") count = 0 for x in (objects) $cmd_utils:suspend_if_needed() for y in ($code_utils:grep_props(x, dobjstr, is_regex, all_matches)) this:tell($html_utils:literal_text(tostr(x, ".", y[1], " (Line ", y[2], ") -> ", y[3]))) count = count + 1 if (count == 100 && player:isa($guardian)) if (!$command_utils:yes_or_no("100 property matches printed. Continue with the spam?", 2)) break x endif elseif (count == 100 && !player:isa($guardian)) player:tell("100 property matches printed. Too much spam. Terminating grep.") break x endif endfor endfor endif if (index(mode, ":")) this:tell("=== ", verb, " of verbs on ", length(objects) == 1 ? $su:nn(objects[1]) | tostr(length(objects), " objects"), " for '", $html_utils:literal_text(dobjstr), "' ===") count = 0 for x in (objects) $cmd_utils:suspend_if_needed() for y in ($code_utils:grep_verbs(x, dobjstr, is_regex, all_matches)) this:tell($html_utils:literal_text(tostr(x, ":", verbs(x)[y[1]], " (Line ", y[2], ") -> ", y[3]))) count = count + 1 if (count == 100 && player:isa($guardian)) if (!$command_utils:yes_or_no("100 verb matches printed. Continue with the spam?", 2)) break x endif elseif (count == 100 && !player:isa($guardian)) player:tell("100 verb matches printed. Too much spam. Terminating grep.") break x endif endfor endfor endif if (index(mode, "!")) this:tell("=== ", verb, " of files on ", length(objects) == 1 ? $su:nn(objects[1]) | tostr(length(objects), " objects"), " for '", $html_utils:literal_text(dobjstr), "' ===") if (!player:tell("[Sorry, file grepping hasn't been implemented yet.]")) count = 0 for x in (objects) $cmd_utils:suspend_if_needed() for y in ($code_utils:grep_files(x, dobjstr, is_regex, all_matches)) this:tell($html_utils:literal_text(tostr(x, "!", y[1], " (Line ", y[2], ") -> ", y[3]))) count = count + 1 if (count == 100 && player:isa($guardian)) if (!$command_utils:yes_or_no("100 file matches printed. Continue with the spam?", 2)) break x endif elseif (count == 100 && !player:isa($guardian)) player:tell("100 file matches printed. Too much spam. Terminating grep.") break x endif endfor endfor endif endif this:tell("=== End of ", verb, " ===") $code_utils:semaphore_exit("grep") "Last modified by Dax (#789) on Thu Dec 13 15:23:32 2001 MST." .