-
2️⃣ @tim_beauchampThe script scripts/cleanup_rubocop_todo_feature_category.rb was generating sed commands that work on GNU sed (Linux) but fail on BSD sed (macOS). The error "invalid command code ." occurred because macOS sed requires a backup extension argument after the -i flag.
Root Cause:
Original problematic command: sed -i "/ - 'spec/workers/every_sidekiq_worker_spec.rb'/d" .rubocop_todo/rspec/feature_category.yml On macOS, sed -i requires a backup extension (even if empty) Solution Implemented:
Modified the cleanup script to generate macOS-compatible sed commands by:
Adding an empty backup extension '' after the -i flag Changing the escaping strategy from single quotes to forward slashes Updated line 70 in the script from: puts "sed -i "/ - '#{escaped_entry}'/d" .rubocop_todo/rspec/feature_category.yml" To: puts "sed -i '' "/ - '#{escaped_entry}'/d" .rubocop_todo/rspec/feature_category.yml" Verified the fix by:
Testing the original problematic command (reproduced the error) Testing the corrected command (worked successfully) Running the modified script to generate 291 corrected sed commands Testing one of the generated commands to confirm it works Result: The script now generates macOS-compatible sed commands like:
sed -i '' "/ - 'spec/workers/every_sidekiq_worker_spec.rb'/d" .rubocop_todo/rspec/feature_category.yml What you can do now:
Run the cleanup script: ruby scripts/cleanup_rubocop_todo_feature_category.rb Copy and paste the generated sed commands directly into your terminal - they will now work on macOS The script correctly identifies 291 spec files with assigned feature_category that should be removed from the rubocop_todo file
Please register or sign in to comment