1
0
Fork
You've already forked ninecp
0
Interactive 9P command-line client
  • Zig 100%
typedlambda 37eb9e4bed release: v0.1.1
Package: ninecp
Source: main @ aadc90236b
2026年03月30日 00:45:00 +02:00
ninecp_test_suite release: v0.1.1 2026年03月30日 00:45:00 +02:00
src release: v0.1.1 2026年03月30日 00:45:00 +02:00
.gitignore release: v0.1.0 2026年03月29日 22:50:36 +02:00
build.zig release: v0.1.1 2026年03月30日 00:45:00 +02:00
build.zig.zon release: v0.1.1 2026年03月30日 00:45:00 +02:00
README.md release: v0.1.1 2026年03月30日 00:45:00 +02:00

ninecp

Interactive 9P command-line client, built on nine_p.

Connects to a 9P server and provides a shell-like interface for browsing and manipulating the namespace. Supports 9P2000, 9P2000.u, and 9P2000.L with automatic negotiation. Includes glob patterns, batch mode, a built-in line editor (ed), and optional line-editing via anyline.

Usage

# Interactive
ninecp localhost:9999
# Single command
ninecp localhost:9999 ls /
# Batch mode
ninecp -b commands.txt localhost:9999
# Verbose (show protocol trace)
ninecp -v localhost:9999 ls /
# Specify dialect
ninecp -d 9P2000 localhost:9999

Options

Flag Description
-p, --port <port> Override port
-d, --dialect <name> Protocol: 9P2000, 9P2000.u, 9P2000.L
-u, --user <name> Username for attach
-a, --aname <name> Attach name
-b, --batchfile <file> Run commands from file (- for stdin)
-q, --quiet Suppress connection messages
-v, --verbose Show protocol trace
-R, --restricted Disable shell commands (!), restrict local paths to cwd

Commands

Navigation

Command Description
ls [path] List directory
ls -l [path] Long listing with permissions, size, timestamps
cd path Change remote directory
pwd Print remote working directory
stat path Show file metadata

File transfer

Command Description
get remote [local] Download file
put local [remote] Upload file
mget pattern Download with glob
mput pattern Upload with glob
cat path Print file contents
more path Page file contents

File operations

Command Description
touch path... Create file or update timestamp
mkdir [-p] [-m mode] path Create directory
rm path Remove file
rmdir path Remove directory
rename old new Rename file
cp src dst Copy file
mv src dst Move file (rename or copy+delete)
ln target link Create hard link (9P2000.L)
ln -s target link Create symbolic link (9P2000.L)

Editing

Command Description
ed path Edit file with built-in line editor

The ed command provides a minimal line editor inspired by Plan 9 ed. It supports a (append), i (insert), c (change), d (delete), p (print), s (substitute), w (write), q (quit), and address ranges. Input mode is terminated by . on a line by itself.

ed works in batch mode -- commands are read from the batch file:

ed /tmp/hello.txt
a
hello world
.
w
q

New files are created automatically on w if they don't exist.

Metadata

Command Description
chmod mode path Change permissions (octal)
chown uid path Change owner (9P2000.u/L)
chgrp gid path Change group (9P2000.u/L)
df [path] Show filesystem statistics (9P2000.L)
version Show negotiated protocol version
umask [mode] Display or set umask (octal)

Local operations

Command Description
lcd path Change local directory
lpwd Print local directory
lls [path] List local directory
lmkdir path Create local directory

Session

Command Description
connect [user@]host[:port] Connect to server
disconnect Disconnect
set [-/+v] Toggle verbose mode
help Show available commands
quit / exit Exit
!command Execute local shell command (disabled with --restricted)

Protocol compatibility

ninecp defaults to requesting 9P2000.L and gracefully degrades:

Feature 9P2000.L 9P2000.u 9P2000
File I/O TLopen/TLcreate TOpen/TCreate TOpen/TCreate
Stat TGetattr TStat TStat
Readdir TReaddir TRead+Stat TRead+Stat
Mkdir TMkdir TCreate+dir TCreate+dir
Rename TRenameat copy+delete copy+delete
Chmod TSetattr TWstat TWstat
Chown/Chgrp TSetattr TWstat n_uid not supported
Symlinks TSymlink not supported not supported
Hard links TLink not supported not supported
Df TStatfs not supported not supported

Batch mode

Batch files contain one command per line. Comments (#) and blank lines are ignored. Special prefixes:

Prefix Effect
- Ignore errors (continue on failure)
^ Expect error (test fails if command succeeds)

Note: ! (shell commands) is not available in batch mode.

# Create and populate a file
touch /tmp/test.txt
ed /tmp/test.txt
a
content here
.
w
q
ls -l /tmp

Restricted mode

ninecp -R (or --restricted) hardens the client for use in untrusted environments:

  • Shell commands disabled: !command returns an error instead of executing
  • Local paths confined: get, put, mget, mput, lcd, lls, lmkdir reject absolute paths (/...) and .. components, confining all local file access to the current working directory and its children
  • Null bytes always rejected: Local paths containing null bytes are rejected regardless of restricted mode (prevents path injection on all platforms)

Dependencies

  • nine_p, clap, anyline (optional)