Skip to content

Update create-package to handle all whitespace characters in sanitization#3

Merged
punppis merged 9 commits into
mainfrom
copilot/update-create-package-sanitization
Jan 29, 2026
Merged

Update create-package to handle all whitespace characters in sanitization#3
punppis merged 9 commits into
mainfrom
copilot/update-create-package-sanitization

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 29, 2026

The create-package tool's sanitization only handled spaces and underscores (tr ' _' '-'), but should convert any run of whitespace characters (spaces, tabs, etc.) into a single dash.

Changes

  • Sanitization logic: Replace tr ' _' '-' with sed 's/[[:space:]]\+/-/g' to collapse any whitespace sequence into a single dash
  • Documentation: Update README to reflect that whitespace runs (not just spaces/underscores) convert to single dashes
  • Examples: Add test cases showing "my ^ repo2"my-repo2 behavior

Example

# Before: "my  ^ repo2" → "my-repo2" (two spaces collapsed incorrectly)
# After: "my  ^ repo2" → "my-repo2" (any whitespace run correctly becomes single dash)

./create-package "my  ^ repo2"
# ✓ Created package 'my-repo2'
#   Script: my-repo2/my-repo2

# Also handles tabs and mixed whitespace
./create-package "test	with		tabs"
# ✓ Created package 'test-with-tabs'

Uses POSIX [[:space:]] class and \+ quantifier, compatible with standard sed on Debian/Ubuntu/Raspberry Pi.

Original prompt

Create a pull request in punppis/linux-utils to update the existing create-package tool sanitization and README documentation.

Context:

Required changes:

  1. Update create-package sanitization to exactly match these rules:
  • Lowercase everything.
  • Convert any run of whitespace characters (spaces, tabs, etc.) into a single dash -.
  • Remove all special characters.
  • Allowed characters in final name: a-z, 0-9, and -.
  • Collapse multiple dashes to a single dash and trim leading/trailing dashes.

Examples:

  • "my repo" -> "my-repo"
  • "my ^ repo2" -> "my-repo2"
  1. Update README.md documentation to reflect the new whitespace rule (runs of whitespace -> single dash) and remove mention of underscores unless still supported explicitly.

Notes:

  • Target environment: Debian/Ubuntu/Raspberry Pi; stick to standard tools available by default (bash, sed, tr).
  • Ensure the tool still accepts package name from stdin or CLI args.

Acceptance criteria:

  • ./create-package "my ^ repo2" creates directory my-repo2 and script my-repo2/my-repo2.
  • Piped input works too.
  • README matches the behavior.

This pull request was created from Copilot chat.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 7 commits January 29, 2026 22:03
Co-authored-by: punppis <6446823+punppis@users.noreply.github.com>
Co-authored-by: punppis <6446823+punppis@users.noreply.github.com>
Co-authored-by: punppis <6446823+punppis@users.noreply.github.com>
Co-authored-by: punppis <6446823+punppis@users.noreply.github.com>
…-package

Co-authored-by: punppis <6446823+punppis@users.noreply.github.com>
Co-authored-by: punppis <6446823+punppis@users.noreply.github.com>
Copilot AI changed the title [WIP] Update sanitization rules for create-package tool Update create-package to handle all whitespace characters in sanitization Jan 29, 2026
Copilot AI requested a review from punppis January 29, 2026 22:11
@punppis punppis marked this pull request as ready for review January 29, 2026 22:23
@punppis punppis merged commit 91f3933 into main Jan 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants