summaryrefslogtreecommitdiff
path: root/appl/cmd/cleanname.b
diff options
context:
space:
mode:
Diffstat (limited to 'appl/cmd/cleanname.b')
-rw-r--r--appl/cmd/cleanname.b45
1 files changed, 45 insertions, 0 deletions
diff --git a/appl/cmd/cleanname.b b/appl/cmd/cleanname.b
new file mode 100644
index 00000000..0883e600
--- /dev/null
+++ b/appl/cmd/cleanname.b
@@ -0,0 +1,45 @@
+implement Cleanname;
+
+include "sys.m";
+ sys: Sys;
+
+include "draw.m";
+
+include "names.m";
+ names: Names;
+
+include "arg.m";
+
+Cleanname: module
+{
+ init: fn(nil: ref Draw->Context, nil: list of string);
+};
+
+init(nil: ref Draw->Context, args: list of string)
+{
+ sys = load Sys Sys->PATH;
+ names = load Names Names->PATH;
+ arg := load Arg Arg->PATH;
+
+ dir: string;
+ arg->init(args);
+ arg->setusage("cleanname [-d pwd] name ...");
+ while((o := arg->opt()) != 0)
+ case o {
+ 'd' =>
+ dir = arg->earg();
+ * =>
+ arg->usage();
+ }
+ args = arg->argv();
+ if(args == nil)
+ arg->usage();
+ arg = nil;
+
+ for(; args != nil; args = tl args){
+ n := hd args;
+ if(dir != nil && n != nil && n[0] != '/' && n[0] != '#')
+ n = dir+"/"+n;
+ sys->print("%s\n", names->cleanname(n)); # %q?
+ }
+}