Commit e0d0de21

e0d0de21c3ccMerged

Yukihiro "Matz" Matsumoto <[email protected]> · 8 months ago · 2 files · +1 added · ~1 modified

Description

Add system-level features: ENV[], Dir.home, system(), backtick, trap, $stdin.getc, format()

Implements 8 new features needed by real programs (ccm):

  • ENV['KEY'] -> getenv(key) with NULL-safe nil comparison
  • Dir.home -> getenv("HOME")
  • system("cmd") -> C system() with sp_last_status tracking
  • cmd (backtick) -> sp_backtick() using popen/pclose
  • trap('SIGNAL') { } -> signal(SIGxxx, SIG_IGN)
  • $stdin.getc -> getchar()
  • $?.success? -> (sp_last_status == 0)
  • format(fmt, args) -> sp_format() using vsnprintf

All 45 tests pass including new bm_system test.

Co-Authored-By: Claude Opus 4.6 (1M context) [email protected]

Details

Commit
e0d0de21c3cc
Parent
a05de0191a33

examples/bm_system.rbaddedView file

1+# Test system features needed for ccm
2+
3+# ENV
4+puts ENV['HOME'] != nil # true
5+
6+# Dir.home
7+home = Dir.home
8+puts home.length > 0 # true
9+
10+# system()
11+system("echo hello_from_system") # hello_from_system
12+
13+# backtick
14+result = `echo backtick_test`.strip
15+puts result # backtick_test
16+
17+# trap (just register, don't trigger)
18+trap('INT') { }
19+puts "trap set"
20+
21+# $stdin — skip interactive test
22+# File.readlink — skip (needs symlink)
23+
24+puts "done"