Skip to content

Unable to diff two file descriptors #232

Description

@danvk

I'd expect webdiff <(cmd1) <(cmd2) to work, but it seems not to:

$ webdiff <(jq . /tmp/base-ll.js) <(jq . data/nyc-lat-lons-ny.js)
Serving diffs on http://localhost:59027
Close the browser tab or hit Ctrl-C when you're done.
======== Running on http://localhost:59027 ========
(Press CTRL+C to quit)
grep: /dev/fd/12: Bad file descriptor
Error handling request
Traceback (most recent call last):
  File "/Users/danvk/.local/pipx/venvs/webdiff/lib/python3.12/site-packages/aiohttp/web_protocol.py", line 452, in _handle_request
    resp = await request_handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/danvk/.local/pipx/venvs/webdiff/lib/python3.12/site-packages/aiohttp/web_app.py", line 543, in _handle
    resp = await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/danvk/.local/pipx/venvs/webdiff/lib/python3.12/site-packages/aiohttp/web_middlewares.py", line 114, in impl
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/danvk/.local/pipx/venvs/webdiff/lib/python3.12/site-packages/webdiff/app.py", line 200, in request_time_middleware
    response = await handler(request)
               ^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/danvk/.local/pipx/venvs/webdiff/lib/python3.12/site-packages/webdiff/app.py", line 124, in handle_diff_ops
    dataclasses.asdict(op) for op in diff.get_diff_ops(DIFF[idx], options)
                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/danvk/.local/pipx/venvs/webdiff/lib/python3.12/site-packages/webdiff/diff.py", line 52, in get_diff_ops
    num_lines = fast_num_lines(b_path)
                ^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/danvk/.local/pipx/venvs/webdiff/lib/python3.12/site-packages/webdiff/diff.py", line 39, in fast_num_lines
    return int(subprocess.check_output(['grep', '-c', '', path]))
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.12/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/subprocess.py", line 466, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.12/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['grep', '-c', '', '/dev/fd/12']' returned non-zero exit status 2.
Shutting down...

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions