Fields that look like numbers compare as strings

Đang mở
#150 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
45/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
rust
Lĩnh vực
cli

Hướng nghiên cứu

Start with the three one-liners in the report and confirm the byte-wise comparison. Then find where AwkValue::StrNum is defined and where record fields are turned into plain strings, since the report says nothing creates StrNum yet. Agree on the approach with the maintainers before editing, because the report asks whether StrNum is the intended design. Done when the three commands match gawk and fields like 1.0 and 50 compare numerically.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

bug

$1 > 100 keeps 50, and $1 == 1 drops 1.0:

$ printf '50 150\n1.0 2\n10 9\n' | awk '$1 > 100'
50 150
$ printf '50 150\n1.0 2\n10 9\n' | awk '$1 == 1'
$ printf '50 150\n1.0 2\n10 9\n' | awk '$1 < $2'
1.0 2
10 9

gawk 5.3.2, mawk and nawk print nothing, 1.0 2, and 50 150 / 1.0 2.

POSIX makes a field that looks like a number a numeric string, so it compares numerically with a number or with another numeric string. Here every field is a plain string (typeof($2) on x 10 prints string; gawk prints strnum), so these comparisons are done byte by byte. The same rule covers getline var, split() elements, ARGV, ENVIRON and -v values.

AwkValue::StrNum exists but nothing creates it yet, so this looks like the planned place for it. Is that the plan? I can send a PR for fields if a direction is agreed.

Checked on main 8f8cf8d.

Ngôn ngữ chính
Rust
Star
31
Fork
13
Merge trung bình
23 giờ 42 phút
Pull request đã merge (30 ngày)
29

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của uutils/awk

Tất cả issue của uutils/awk

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.