# A workaround is to use parenthesis or a backslash:
folder-hook (@imap.example.com) "set sort=threads"
-folder-hook \@imap.example.com "set sort=threads"
+folder-hook '\@imap.example.com' "set sort=threads"
</screen>
<para>
Keep in mind that mailbox shortcut expansion on the regexp parameter
takes place when the hook is initially parsed, not when the hook is
-matching against a mailbox.
+matching against a mailbox. When Mutt starts up and is reading the
+.muttrc, some mailbox shortcuts may not be usable. For example, the
+"current mailbox" shortcut, ^, will expand to an empty string because no
+mailbox has been opened yet. Mutt will issue an error for this case or
+if the mailbox shortcut results in an empty regexp.
</para>
</sect2>
if (data & (M_FOLDERHOOK | M_MBOXHOOK))
{
+ /* Accidentally using the ^ mailbox shortcut in the .muttrc is a
+ * common mistake */
+ if ((*pattern.data == '^') && (! CurrentFolder))
+ {
+ strfcpy (err->data, _("current mailbox shortcut '^' is unset"), err->dsize);
+ goto error;
+ }
+
strfcpy (path, pattern.data, sizeof (path));
_mutt_expand_path (path, sizeof (path), 1);
+
+ /* Check for other mailbox shortcuts that expand to the empty string.
+ * This is likely a mistake too */
+ if (!*path && *pattern.data)
+ {
+ strfcpy (err->data, _("mailbox shortcut expanded to empty regexp"), err->dsize);
+ goto error;
+ }
+
FREE (&pattern.data);
memset (&pattern, 0, sizeof (pattern));
pattern.data = safe_strdup (path);