aboutsummaryrefslogtreecommitdiffstats
path: root/CLAUDE.md
blob: b2b928b336b2b0e11bcd8bd3a6df5d0a1d0a5472 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## What this is

`is_installed` is a single Bash script for Slackware (and derivatives) that queries the package database in `/var/log/packages` (each installed package = one file there). No build, no tests, no dependencies beyond Bash + coreutils + grep.

## Layout

- `is_installed` — the script. All logic lives here.
- `is_installed.bash-completion` — bash completion. Sourced/installed separately (e.g. into `/usr/share/bash-completion/completions/is_installed`).

## Install

The user runs this from `~/bin` (which is on their PATH). Install the script with:

```
install -Dm0755 is_installed ~/bin/is_installed
```

Re-run that after editing to deploy. The bash completion is optional and
installed separately:

```
install -m0644 is_installed.bash-completion \
    /usr/share/bash-completion/completions/is_installed
```

Note: `is_installed help` exits `69` (`SHOWHELP`), not `0`. That is by design,
not a failure.

## Architecture

Dispatch happens at the bottom `case` on `$1`:
- `file-search <item>``search_file()`: greps file contents of every package manifest in `$PKGS_PATH`, groups hits by package name.
- `info <item>``info()`: `less` the matching manifest.
- `help``help()`.
- anything else → treated as a package-name query → `search_package()`: lists `$PKGS_PATH` and greps the names.

`PKGS_PATH` (`/var/log/packages`) is the single source of truth and is hardcoded. The completion script mirrors this path in the `info` case, so changing the path means editing both files.

Exit codes are named vars at the top: `SHOWHELP=69`, `E_NOPKGFOUND=70`, `E_NOARGS=71`. Reuse these rather than literals.

Output uses ANSI color vars (`RED`/`ORANGE`/`GREEN`/`MAGENTA`/`NC`) with `echo -e`. Match this style for any new user-facing output.