</varlistentry>
<varlistentry>
- <term><option>-b <optional><replaceable>ID</replaceable></optional><optional><replaceable>±offset</replaceable></optional></option></term>
- <term><option>--boot=<optional><replaceable>ID</replaceable></optional><optional><replaceable>±offset</replaceable></optional></option></term>
+ <term><option>-b <optional><optional><replaceable>ID</replaceable></optional><optional><replaceable>±offset</replaceable></optional>|<constant>all</constant></optional></option></term>
+ <term><option>--boot<optional>=<optional><replaceable>ID</replaceable></optional><optional><replaceable>±offset</replaceable></optional>|<constant>all</constant></optional></option></term>
<listitem><para>Show messages from a specific boot. This will
add a match for <literal>_BOOT_ID=</literal>.</para>
<replaceable>offset</replaceable> is not specified, a value of
zero is assumed, and the logs for the boot given by
<replaceable>ID</replaceable> are shown.</para>
+
+ <para>The special argument <constant>all</constant> can be
+ used to negate the effect of an earlier use of
+ <option>-b</option>.</para>
</listitem>
</varlistentry>
sd_id128_t id = SD_ID128_NULL;
int off = 0, r;
- if (strlen(x) >= 32) {
+ if (streq(x, "all")) {
+ *boot_id = SD_ID128_NULL;
+ *offset = 0;
+ return 0;
+ } else if (strlen(x) >= 32) {
char *t;
t = strndupa(x, 32);
if (offset)
*offset = off;
- return 0;
+ return 1;
}
static int help(void) {
case ARG_THIS_BOOT:
arg_boot = true;
+ arg_boot_id = SD_ID128_NULL;
+ arg_boot_offset = 0;
break;
case 'b':
arg_boot = true;
+ arg_boot_id = SD_ID128_NULL;
+ arg_boot_offset = 0;
if (optarg) {
r = parse_boot_descriptor(optarg, &arg_boot_id, &arg_boot_offset);
- if (r < 0) {
- log_error("Failed to parse boot descriptor '%s'", optarg);
- return -EINVAL;
- }
- } else {
+ if (r < 0)
+ return log_error_errno(r, "Failed to parse boot descriptor '%s'", optarg);
- /* Hmm, no argument? Maybe the next
- * word on the command line is
- * supposed to be the argument? Let's
- * see if there is one and is parsable
- * as a boot descriptor... */
+ arg_boot = r;
- if (optind < argc &&
- parse_boot_descriptor(argv[optind], &arg_boot_id, &arg_boot_offset) >= 0)
+ /* Hmm, no argument? Maybe the next
+ * word on the command line is
+ * supposed to be the argument? Let's
+ * see if there is one and is parsable
+ * as a boot descriptor... */
+ } else if (optind < argc) {
+ r = parse_boot_descriptor(argv[optind], &arg_boot_id, &arg_boot_offset);
+ if (r >= 0) {
+ arg_boot = r;
optind++;
+ }
}
-
break;
case ARG_LIST_BOOTS:
! grep -q '^FOO=' /output
! grep -q '^SYSLOG_FACILITY=' /output
+# `-b all` negates earlier use of -b (-b and -m are otherwise exclusive)
+journalctl -b -1 -b all -m > /dev/null
+
+# -b always behaves like -b0
+journalctl -q -b-1 -b0 | head -1 > /expected
+journalctl -q -b-1 -b | head -1 > /output
+cmp /expected /output
+# ... even when another option follows (both of these should fail due to -m)
+{ journalctl -ball -b0 -m 2>&1 || :; } | head -1 > /expected
+{ journalctl -ball -b -m 2>&1 || :; } | head -1 > /output
+cmp /expected /output
+
# Don't lose streams on restart
systemctl start forever-print-hola
sleep 3