commit cfd437523755fd2f185176c5065bd8209c68cad5
parent 28fd5ade1800dca11489a48cf7a571293a63bbb9
Author: Jacob R. Edwards <jacobouno@protonmail.com>
Date: Tue, 5 Jan 2021 01:35:05 -0800
Add type 7 support in cgoto()
Diffstat:
1 file changed, 23 insertions(+), 5 deletions(-)
diff --git a/command.c b/command.c
@@ -71,15 +71,33 @@ cfetch(int argc, char const **argv, int ino, char const **item)
return PASS;
}
+LOCAL int
+cgoto7(int argc, char const **argv, int ino, char const **item)
+{
+ char tmp[MY_PATH_MAX];
+
+ if (warg(2, 2, argc, argv))
+ return FAIL;
+ if (**item != '7') {
+ warnc(EFTYPE, "%d", ino);
+ return FAIL;
+ }
+
+ /* NOTE: the user inserts `?` for a space */
+ snprintf(tmp, sizeof(tmp), "%s?%s", item[GI_PATH], argv[1]);
+ item[GI_PATH] = tmp;
+ return gawk(itemtoaddr(item));
+}
+
int
cgoto(int argc, char const **argv, int ino, char const **item)
{
- warg(1, 1, argc, argv);
- /* TODO: implement 7 type support */
- if (**item == '1')
+ if (**item == '1') {
+ if (warg(1, 1, argc, argv))
+ return FAIL;
return gawk(itemtoaddr(item));
- warnc(EFTYPE, "%d", ino);
- return NEXT;
+ }
+ return cgoto7(argc, argv, ino, item);
}
int