Skip to content

BAT_CONFIG_DIR pointing at system bat config directory causes options to be applied twice (duplicate flag error) #3589

@jeremypass96

Description

@jeremypass96

What steps will reproduce the bug?

  1. Create a system-wide config directory/file in /etc/bat/config.
  2. Uncomment the "#--italic-text=always" line.
  3. Update the environment with BAT_CONFIG_DIR="/etc/bat" in /etc/environment, and then source /etc/environment.
  4. Open any file with bat. It will error out here.
  5. Set BAT_CONFIG_DIR="/etc/bat" instead to BAT_CONFIG_PATH="/etc/bat", and the error goes away.

What happens?

bat throws an error that says "error: the argument '--italic-text ' cannot be used multiple times".

What did you expect to happen instead?

A file to open without any error.

How did you install bat?

Portage/emerge from Gentoo.


bat version and environment

Software version

bat 0.26.1

Operating system

  • OS: Linux (Gentoo 2.18)
  • Kernel: 6.18.8-gentoo-dist

Command-line

bat --diagnostic 

Environment variables

BAT_CACHE_PATH=<not set>
BAT_CONFIG_PATH=<not set>
BAT_OPTS=<not set>
BAT_PAGER=<not set>
BAT_PAGING=<not set>
BAT_STYLE=<not set>
BAT_TABS=<not set>
BAT_THEME=<not set>
COLORTERM=truecolor
LANG=en_US.UTF-8
LC_ALL=<not set>
LESS='-sFRiMX --shift 5'
MANPAGER=manpager
NO_COLOR=<not set>
PAGER=less
SHELL=/bin/zsh
TERM=xterm-256color
XDG_CACHE_HOME=/home/jeremy/.cache
XDG_CONFIG_HOME=/home/jeremy/.config

System Config file

# This is `bat`s configuration file. Each line either contains a comment or
# a command-line option that you want to pass to `bat` by default. You can
# run `bat --help` to get a list of all possible configuration options.

# Specify desired highlighting theme (e.g. "TwoDark"). Run `bat --list-themes`
# for a list of all available themes
--theme="Catppuccin Mocha"
--style="numbers,changes,header,grid"

# Enable this to use italic text on the terminal. This is not supported on all
# terminal emulators (like tmux, by default):
--italic-text=always

# Uncomment the following line to disable automatic paging:
#--paging=never

# Uncomment the following line if you are using less version >= 551 and want to
# enable mouse scrolling support in `bat` when running inside tmux. This might
# disable text selection, unless you press shift.
#--pager="less --RAW-CONTROL-CHARS --quit-if-one-screen --mouse"

# Syntax mappings: map a certain filename pattern to a language.
#   Example 1: use the C++ syntax for Arduino .ino files
#   Example 2: Use ".gitignore"-style highlighting for ".ignore" files
#--map-syntax "*.ino:C++"
--map-syntax ".ignore:Git Ignore"
--map-syntax "*.conf:INI"
--map-syntax "config:INI"

Config file

# This is `bat`s configuration file. Each line either contains a comment or
# a command-line option that you want to pass to `bat` by default. You can
# run `bat --help` to get a list of all possible configuration options.

# Specify desired highlighting theme (e.g. "TwoDark"). Run `bat --list-themes`
# for a list of all available themes
--theme="Catppuccin Mocha"
--style="numbers,changes,header,grid"

# Enable this to use italic text on the terminal. This is not supported on all
# terminal emulators (like tmux, by default):
--italic-text=always

# Uncomment the following line to disable automatic paging:
#--paging=never

# Uncomment the following line if you are using less version >= 551 and want to
# enable mouse scrolling support in `bat` when running inside tmux. This might
# disable text selection, unless you press shift.
#--pager="less --RAW-CONTROL-CHARS --quit-if-one-screen --mouse"

# Syntax mappings: map a certain filename pattern to a language.
#   Example 1: use the C++ syntax for Arduino .ino files
#   Example 2: Use ".gitignore"-style highlighting for ".ignore" files
#--map-syntax "*.ino:C++"
--map-syntax ".ignore:Git Ignore"
--map-syntax "*.conf:INI"
--map-syntax "config:INI"

Custom assets metadata

bat_version: 0.26.1
creation_time:
  secs_since_epoch: 1771539643
  nanos_since_epoch: 823875901

Custom assets

  • metadata.yaml, 97 bytes
  • syntaxes.bin, 1012454 bytes
  • themes.bin, 58318 bytes

Compile time information

  • Profile: release
  • Target triple: x86_64-unknown-linux-gnu
  • Family: unix
  • OS: linux
  • Architecture: x86_64
  • Pointer width: 64
  • Endian: little
  • CPU features: aes,avx,bmi1,cmpxchg16b,f16c,fma,fxsr,lzcnt,pclmulqdq,popcnt,sse,sse2,sse3,sse4.1,sse4.2,sse4a,ssse3,tbm,xsave
  • Host: x86_64-unknown-linux-gnu

Less version

> less --version 
less 692 (PCRE2 regular expressions)
Copyright (C) 1984-2026  Mark Nudelman

less comes with NO WARRANTY, to the extent permitted by law.
For information about the terms of redistribution,
see the file named README in the less distribution.
Home page: https://greenwoodsoftware.com/less

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions