-
Notifications
You must be signed in to change notification settings - Fork 1
Allowed Commands v1 #88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
deef1c7
6dc189c
75db43f
2122329
64e0229
4748471
d833bb2
37a3ea0
49ca2e3
06ebddf
549eac5
96118af
95dd71c
a1b1823
23e413a
c17f32e
fe975c0
54e28da
c6a790b
a2f1fe4
26c0c92
89ea191
3083682
615dfcb
96d56bc
f019c0c
b6cc8c8
fe241af
001fb91
38bb825
088739f
052bd07
0f2d9f7
b32161f
b488c50
04ef3ae
00ebaaf
7aa845f
07371a1
b5501c7
77b8af9
f3d1d51
47de068
c2ed053
37758ed
d4c7257
c3cae87
6f2c191
f77e998
72e02fe
7953da1
b2c3cfc
ac9c059
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -384,6 +384,23 @@ func listDir(ctx context.Context, callCtx *builtins.CallContext, dir string, opt | |
| // so no post-sort slicing is needed. The effectiveLimit is already | ||
| // enforced by readDir's maxRead parameter. | ||
|
|
||
| // Print total line for long format (matching GNU ls behaviour). | ||
| // GNU ls prints "total <blocks>" where blocks are 1024-byte (1K) blocks | ||
| // by default. Since syscall.Stat_t is not available (import restriction), | ||
| // we approximate using file sizes: blocks = ceil(size / 1024) per file, | ||
| // with directories counting as 0 blocks (matching GNU ls on most FSes | ||
| // where directory size varies). | ||
| if opts.longFmt { | ||
| var totalBlocks int64 | ||
| for _, ei := range infoEntries { | ||
| if !ei.info.IsDir() { | ||
| sz := ei.info.Size() | ||
| totalBlocks += (sz + 1023) / 1024 | ||
| } | ||
|
Comment on lines
+395
to
+399
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The new Useful? React with 👍 / 👎. |
||
| } | ||
| callCtx.Outf("total %d\n", totalBlocks) | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The comment already acknowledges this, and all |
||
| } | ||
|
|
||
| // Print. | ||
| for _, ei := range infoEntries { | ||
| if ctx.Err() != nil { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new long-format total uses
ceil(size/1024)and skips directories, but GNU/bashls -ltotals are based on allocated filesystem blocks (st_blocks), not logical byte size, so this prints systematically incorrect totals (for example, a 1-byte file commonly showstotal 4in bash buttotal 1here). Because this feature is meant to matchlssemantics, the current calculation introduces observable bash-incompatibility.Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Claude Opus 4.6] This is an intentional simplification. The code comment (lines 388-392) already explains:
syscall.Stat_tis not available because thesyscallpackage is banned by the import allowlist. GNU ls usesst_blocks(allocated filesystem blocks), but withoutsyscallwe can only approximate using logical file sizes. This is a known trade-off documented in the long-format section of the ls package doc (line 49-52). Leaving unresolved for the reviewer.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Claude Opus 4.6] Confirming this is an intentional limitation — the
syscallpackage is banned by the import allowlist, sost_blocks(allocated filesystem blocks) is not accessible. The code usesceil(size/1024)as the best available approximation. This is documented in the code comments. The test scenarios forls -luseskip_assert_against_bash: truefor this reason. Leaving unresolved for reviewer to confirm this trade-off is acceptable.