Skip to content
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

command | rg keyword doesn't work (ripgrep) #879

Open
kkebo opened this issue Dec 28, 2024 · 2 comments
Open

command | rg keyword doesn't work (ripgrep) #879

kkebo opened this issue Dec 28, 2024 · 2 comments

Comments

@kkebo
Copy link
Contributor

kkebo commented Dec 28, 2024

Summary

command | rg keyword doesn't work.

Steps to reproduce

prerequisite: pkg install rg

  1. Run help -l | rg wasm3

Expected behavior

$ help -l | rg wasm3
ctags.wasm3
file.wasm3
mktemp.wasm3
readtags.wasm3
rg.wasm3
swift-format-main.wasm3
swift-format.wasm3
tree.wasm3
wasm3
xz.wasm3
xzdec.wasm3

Actual behavior

$ help -l | rg wasm3
a-shell/Resources_mini/commandDictionary.plist
908:    <key>wasm3</key>
911:            <string>wasm3</string>

a-shell/Resources_mini/node_modules/@wasmer/wasi/lib/constants.js
281:// a-Shell: this was reversed from wasm32-wasi/predefined-macros.txt

a-shell/a-Shell/ExtraCommands.swift
74:        fputs("JIT webAssembly is not available \"In Extension\". Try \"wasm3\".\n", thread_stderr)

a-shell/a-Shell/AppDelegate.swift
296:            setenv("CCC_OVERRIDE_OPTIONS", "#^--target=wasm32-wasip1 ^-fwasm-exceptions +-lunwind", 1) // silently add "--target=wasm32-wasi" at the beginning of arguments and "-lunwind" at the end.

a-shell/a-Shell/SceneDelegate.swift
3060:                    let unzipPath = documentsUrl.appendingPathComponent("bin/unzip.wasm3").path
3071:                    let xzPath = documentsUrl.appendingPathComponent("bin/xz.wasm3").path
4115:                if (compileOptions.isEqual("#^--target") || compileOptions.isEqual("#^--target=wasm32-wasi")) {
4116:                    setenv("CCC_OVERRIDE_OPTIONS", "#^--target=wasm32-wasip1 ^-fwasm-exceptions +-lunwind", 1)

a-shell/Resources/commandDictionary.plist
971:    <key>wasm3</key>
974:            <string>wasm3</string>

a-shell/Resources/node_modules/parcel-bundler/lib/assets/RustAsset.js
32:const RUST_TARGET = 'wasm32-unknown-unknown';

a-shell/Resources/node_modules/parcel-bundler/src/assets/RustAsset.js
13:const RUST_TARGET = 'wasm32-unknown-unknown';

a-shell/Resources/node_modules/@wasmer/wasi/lib/constants.js
281:// a-Shell: this was reversed from wasm32-wasi/predefined-macros.txt

a-shell/Resources/usr_old/include/c++/v1/__cxxabi_config.h
87:// wasm32 follows the arm32 ABI convention of using 32-bit guard.
88:#if defined(__arm__) || defined(__wasm32__) || defined(__ARM64_ARCH_8_32__)

a-shell/Resources/usr_old/include/wasi/api.h
23:#ifndef __wasm32__
24:#error <wasi/api.h> only supports wasm32; doesn't yet support wasm64

a-shell/Resources/usr_old/share/wasm32-wasi/predefined-macros.txt
3149:#define __wasm32 1
3150:#define __wasm32__ 1

Environment

  • iPadOS 18.3 Developer Beta 1
  • a-Shell 1.15.10 (App Store)
@holzschu
Copy link
Owner

holzschu commented Jan 2, 2025

I can reproduce this issue. I'm working on it, but I'm not sure I will be able to fix it.
It also fails with the standard interpreter (help -l | wasm rg.wasm3) instead of the wasm3 interpreter. Based on the results, rg is scanning the current working directory instead of scanning the standard input, but I'm not sure why.

rg calls fdstat_get twice, with fd equals 1, then 0, then calls prestat_get with fd equals 3, 4, then 5.

@holzschu
Copy link
Owner

holzschu commented Jan 3, 2025

I spoke too fast: it turns out rg checks whether stdin is readable (in crates/cli/src/lib.rs), and defaults to false on non-Unix, non-Windows targets (and wasi is not considered a part of Unix). I've added a few lines so that stdin is always readable on wasi, and now help -l | rg wasm3 works. I'll let you test it for a while, if you want.

There will obviously be an issue if stdin is not readable, but I don't see a clear way to check for that (also I don't know how that can happen in a-Shell).

rg.wasm3.zip

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

No branches or pull requests

2 participants