/usr/lib/ruby/vendor_ruby/sass/repl.rb is in ruby-sass 3.4.6-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | require 'readline'
module Sass
# Runs a SassScript read-eval-print loop.
# It presents a prompt on the terminal,
# reads in SassScript expressions,
# evaluates them,
# and prints the result.
class Repl
# @param options [{Symbol => Object}] An options hash.
def initialize(options = {})
@options = options
end
# Starts the read-eval-print loop.
def run
environment = Environment.new
@line = 0
loop do
@line += 1
unless (text = Readline.readline('>> '))
puts
return
end
Readline::HISTORY << text
parse_input(environment, text)
end
end
private
def parse_input(environment, text)
case text
when Script::MATCH
name = $1
guarded = !!$3
val = Script::Parser.parse($2, @line, text.size - ($3 || '').size - $2.size)
unless guarded && environment.var(name)
environment.set_var(name, val.perform(environment))
end
p environment.var(name)
else
p Script::Parser.parse(text, @line, 0).perform(environment)
end
rescue Sass::SyntaxError => e
puts "SyntaxError: #{e.message}"
if @options[:trace]
e.backtrace.each do |line|
puts "\tfrom #{line}"
end
end
end
end
end
|