# File lib/puppet/provider/augeas/augeas.rb, line 257
257:   def need_to_run?
258:     force = resource[:force]
259:     return_value = true
260:     begin
261:       open_augeas
262:       filter = resource[:onlyif]
263:       unless filter == ""
264:         cmd_array = parse_commands(filter)[0]
265:         command = cmd_array[0];
266:         begin
267:           case command
268:           when "get"; return_value = process_get(cmd_array)
269:           when "match"; return_value = process_match(cmd_array)
270:           end
271:         rescue SystemExit,NoMemoryError
272:           raise
273:         rescue Exception => e
274:           fail("Error sending command '#{command}' with params #{cmd_array[1..-1].inspect}/#{e.message}")
275:         end
276:       end
277: 
278:       unless force
279:         # If we have a verison of augeas which is at least 0.3.6 then we
280:         # can make the changes now, see if changes were made, and
281:         # actually do the save.
282:         if return_value and get_augeas_version >= "0.3.6"
283:           debug("Will attempt to save and only run if files changed")
284:           set_augeas_save_mode(SAVE_NOOP)
285:           do_execute_changes
286:           save_result = @aug.save
287:           saved_files = @aug.match("/augeas/events/saved")
288:           if save_result and not files_changed?
289:             debug("Skipping because no files were changed")
290:             return_value = false
291:           else
292:             debug("Files changed, should execute")
293:           end
294:         end
295:       end
296:     ensure
297:       close_augeas
298:     end
299:     return_value
300:   end