diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 629b484cfe888c7c80cd3759aad8cf39d1a5b474..6bc4541d04841655f56fd204e40bf02554779a01 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -36,8 +36,7 @@ build package:
 
 check whitespace style:
   stage: build
-  script:
-    - "! for f in `git ls-files | grep -v \\.diff$`; do file $f | grep -q ' text' || continue; grep -q '[[:blank:]]$' $f && echo $f: trailing whitespace; tail -n1 $f | read -r _ || echo $f: no newline at end of file; tail -n1 $f | grep -q '^$' && echo $f: empty line at end of file; done | grep . >&2"
+  script: ./check_whitespace
   allow_failure: true
 
 check for dependencies installed:
diff --git a/check_whitespace b/check_whitespace
new file mode 100755
index 0000000000000000000000000000000000000000..a0afee7bb3c8c583f9b04e87318bb2ed30e64403
--- /dev/null
+++ b/check_whitespace
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+! for f in $(git ls-files | grep -v \\.diff$); do
+    file $f | grep -q ' text' || continue
+    grep -q '[[:blank:]]$' $f && echo $f: trailing whitespace
+    tail -n1 $f | read -r _ || echo $f: no newline at end of file
+    tail -n1 $f | grep -q '^$' && echo $f: empty line at end of file
+done | grep . >&2