mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-14 22:11:16 -03:00
Use set -l to force use of a local variable
Bare set overwrites a global/universal variable if it exists.
This commit is contained in:
@@ -5,31 +5,31 @@
|
||||
#
|
||||
# Usage: ./diff_profiles.fish profile1.log profile2.log > profile_diff.log
|
||||
|
||||
set profile1 (cat $argv[1])
|
||||
set profile2 (cat $argv[2])
|
||||
set -l profile1 (cat $argv[1])
|
||||
set -l profile2 (cat $argv[2])
|
||||
|
||||
set line_no 0
|
||||
while set next_line_no (math $line_no + 1) && set -q profile1[$next_line_no] && set -q profile2[$next_line_no]
|
||||
set -l line_no 0
|
||||
while set -l next_line_no (math $line_no + 1) && set -q profile1[$next_line_no] && set -q profile2[$next_line_no]
|
||||
set line_no $next_line_no
|
||||
|
||||
set line1 $profile1[$line_no]
|
||||
set line2 $profile2[$line_no]
|
||||
set -l line1 $profile1[$line_no]
|
||||
set -l line2 $profile2[$line_no]
|
||||
|
||||
if not string match -qr '^\d+\t\d+' $line1
|
||||
echo $line1
|
||||
continue
|
||||
end
|
||||
|
||||
set results1 (string match -r '^(\d+)\t(\d+)\s+(.*)' $line1)
|
||||
set results2 (string match -r '^(\d+)\t(\d+)\s+(.*)' $line2)
|
||||
set -l results1 (string match -r '^(\d+)\t(\d+)\s+(.*)' $line1)
|
||||
set -l results2 (string match -r '^(\d+)\t(\d+)\s+(.*)' $line2)
|
||||
|
||||
# times from both files
|
||||
set time1 $results1[2..3]
|
||||
set time2 $results2[2..3]
|
||||
set -l time1 $results1[2..3]
|
||||
set -l time2 $results2[2..3]
|
||||
|
||||
# leftover from both files
|
||||
set remainder1 $results1[4]
|
||||
set remainder2 $results2[4]
|
||||
set -l remainder1 $results1[4]
|
||||
set -l remainder2 $results2[4]
|
||||
|
||||
if not string match -q -- $remainder1 $remainder2
|
||||
echo Mismatch on line $line_no:
|
||||
|
||||
Reference in New Issue
Block a user