[gnome-code-assistance] sh: Use bash dry-run mode only if shellcheck is not installed
- From: Elad Alfassa <eladalfassa src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-code-assistance] sh: Use bash dry-run mode only if shellcheck is not installed
- Date: Thu, 25 Aug 2016 14:10:08 +0000 (UTC)
commit b8f80c26bf20d9d1d25f30b036351609731d4f12
Author: Elad Alfassa <elad fedoraproject org>
Date: Thu Aug 25 17:07:57 2016 +0300
sh: Use bash dry-run mode only if shellcheck is not installed
backends/sh/__init__.py | 37 ++++++++++++++++++-------------------
1 files changed, 18 insertions(+), 19 deletions(-)
---
diff --git a/backends/sh/__init__.py b/backends/sh/__init__.py
index 1266af9..6b4acf6 100644
--- a/backends/sh/__init__.py
+++ b/backends/sh/__init__.py
@@ -36,23 +36,6 @@ class Service(transport.Service):
doc.diagnostics = []
try:
- p = subprocess.Popen(["/bin/bash", "-n", doc.data_path], stdout=DEVNULL, stderr=subprocess.PIPE)
-
- for l in iter(p.stderr.readline, ''):
- if not l:
- break
-
- m = Service.pattern.match(l.decode())
- if m:
- loc = types.SourceLocation(line=m.group(1))
-
- doc.diagnostics.append(types.Diagnostic(severity=types.Diagnostic.Severity.ERROR,
- locations=[loc.to_range()],
- message=m.group(2)))
- except Error as e:
- pass
-
- try:
p = subprocess.Popen(['shellcheck', '-f', 'gcc', doc.data_path],
stdout=subprocess.PIPE)
for line in iter(p.stdout.readline, ''):
@@ -71,8 +54,24 @@ class Service(transport.Service):
locations=[loc.to_range()],
message=result[3]))
except FileNotFoundError:
- # shellcheck is not installed. Do nothing.
- pass
+ # shellcheck is not installed. Check with bash dry run mode instead.
+ try:
+ p = subprocess.Popen(["/bin/bash", "-n", doc.data_path],
+ stdout=DEVNULL, stderr=subprocess.PIPE)
+
+ for l in iter(p.stderr.readline, ''):
+ if not l:
+ break
+
+ m = Service.pattern.match(l.decode())
+ if m:
+ loc = types.SourceLocation(line=m.group(1))
+
+ doc.diagnostics.append(types.Diagnostic(severity=types.Diagnostic.Severity.ERROR,
+ locations=[loc.to_range()],
+ message=m.group(2)))
+ except Exception as e:
+ pass
def dispose(self, doc):
pass
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]