diff options
| author | Andre Noll <maan@tuebingen.mpg.de> | 2026-02-25 22:33:54 +0100 |
|---|---|---|
| committer | Andre Noll <maan@tuebingen.mpg.de> | 2026-03-17 19:25:05 +0100 |
| commit | 353c4cd671005dd75bbef6fef4e71a138ba5c170 (patch) | |
| tree | 26890257f6003806b01ee5be031b3c933b786b28 | |
| parent | e279a5b71c2d8f3e9ec0efd6c291381f36170512 (diff) | |
com_ls(): Make ls --admissible=- work.
We support "-" as the argument to the select subcommand as a shortcut for the
name of the previously loaded mood or playlist. However, ls --admissible=-
fails. This is inconsistent, so patch the ls subcommand to support this
as well.
Since the name of the previous mood or playlist is currently only known to
afs.c, we have to declare previous_mop in afs.h and make it non-static in
afs.c. Do the same with current_mop for consistency.
| -rw-r--r-- | afs.c | 2 | ||||
| -rw-r--r-- | afs.h | 5 | ||||
| -rw-r--r-- | aft.c | 9 |
3 files changed, 14 insertions, 2 deletions
@@ -84,7 +84,7 @@ static int server_socket; static struct command_task command_task_struct; static struct signal_task *signal_task; -static char *current_mop, *previous_mop; /* NULL means dummy mood */ +char *current_mop, *previous_mop; /* NULL means dummy mood */ extern uint32_t afs_socket_cookie; @@ -308,6 +308,11 @@ extern enum selector_id current_selector_id, previous_selector_id; extern const struct selector_operations *selector_ops[NUM_SELECTORS]; /** The mood or playlist currently active. */ extern struct selector_instance *current_selector_instance; +/** Name of the current mood or playlist, including the {m,p}/ prefix. */ +extern char *current_mop; +/** Name of the previous mood or playlist. */ +extern char *previous_mop; + /** * Get the selector operations of the current mood or playlist. * @@ -1308,7 +1308,14 @@ static int mop_loop(const char *arg, struct afs_callback_arg *aca, return 0; return current_selector()->loop(si, prepare_ls_row, opts); } - if (!strncmp(arg, "m/", 2)) + if (!strcmp(arg, "-")) { /* load previous mop */ + ops = selector_ops[previous_selector_id]; + if (!previous_mop) { + afs_error(aca, "no previous mood/playlist\n"); + return -ERRNO_TO_PARA_ERROR(EINVAL); + } + arg = previous_mop; + } else if (!strncmp(arg, "m/", 2)) ops = selector_ops[SEL_MOOD]; else if (!strncmp(arg, "p/", 2)) ops = selector_ops[SEL_PLAYLIST]; |
