Skip to content

The options --map-syntax and --ignored-suffix cannot work together. #2093

@edentsai

Description

@edentsai

Describe the bug you encountered:

The options --map-syntax and --ignored-suffix cannot work together.

How to reproduce it:

  1. Prepare a file foo.demo in YAML syntax:

    # file: foo.demo
    foo: "bar"
  2. Use bat --map-syntax "*.demo:YAML" foo.demo can print it with YAML syntax highlighting:

    bat foo.demo \
        --map-syntax "*.demo:YAML" 
  3. Copy foo.demo to foo.demo.example,
    and use bat --map-syntax "*.demo:YAML" --ignored-suffix ".example" foo.demo.example CANNOT print it with YAML syntax highlighting:

    cp "foo.demo"  "foo.demo.example"
    bat foo.demo.example \
        --map-syntax "*.demo:YAML" \
        --ignored-suffix ".example"
    # CANNOT print `foo.demo.example` with YAML syntax.
  4. BUT it works well If I only use --ignored-suffix ".example" with built-in syntax mapping:

    # Use built-in syntax mapping (YAML):
    cp foo.demo.example foo.yaml.example
    bat foo.yaml.example \
        --ignored-suffix ".example"

What did you expect to happen instead?

The options --map-syntax and --ignored-suffix can works togerher.

bat foo.demo.example \
    --map-syntax "*.demo:YAML" \
    --ignored-suffix ".example"
# I expect it can print `foo.demo.example` with YAML syntax.

How did you install bat?

Homebrew:

brew install --formula "bat"

bat version and environment

Software version

bat 0.20.0

Operating system

macOS 12.2 (Darwin 21.3.0)

Command-line

bat foo.demo.example --ignored-suffix .example --diagnostic 

Environment variables

SHELL=/opt/homebrew/bin/bash
PAGER=<not set>
LESS='--no-init --quit-if-one-screen --ignore-case --status-column --LONG-PROMPT --RAW-CONTROL-CHARS --HILITE-UNREAD --tabs=4 --window=-6 '
LANG=en_US.UTF-8
LC_ALL=en_US.UTF-8
BAT_PAGER=<not set>
BAT_CACHE_PATH=<not set>
BAT_CONFIG_PATH=<not set>
BAT_OPTS=<not set>
BAT_STYLE=<not set>
BAT_TABS=<not set>
BAT_THEME=<not set>
XDG_CONFIG_HOME=~/.config
XDG_CACHE_HOME=~/.cache
COLORTERM=truecolor
NO_COLOR=<not set>
MANPAGER='sh -c '\''col -b -x | bat --language "man" --style "plain"'\'''

Config file

Could not read contents of '~/.config/bat/config': No such file or directory (os error 2).

Compile time information

  • Profile: release
  • Target triple: aarch64-apple-darwin
  • Family: unix
  • OS: macos
  • Architecture: aarch64
  • Pointer width: 64
  • Endian: little
  • CPU features: unknown
  • Host: aarch64-apple-darwin

Less version

> less --version 
less 590 (PCRE2 regular expressions)
Copyright (C) 1984-2021  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

thanks for this awesome tool.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions